Chat completions

The request and response follow the OpenAI Chat Completions schema. Fields marked supported are forwarded; everything else is dropped before the upstream call.

Supported fields

FieldNotes
modelRequired. Must be a FreeGate model id, not an upstream id.
messagesRequired. Text parts, plus images and files where the model supports them.
max_completion_tokensClamped to the operator's per-request ceiling; the live value is on status.
temperature, top_pForwarded as-is.
stopString or array of strings.
presence_penalty, frequency_penaltyForwarded as-is.
seedForwarded when the model supports it.
toolsForwarded. Function tools only; up to 128 definitions.
tool_choice, parallel_tool_callsForwarded with tools.
streamSee streaming.

Messages

All four roles are accepted, including tool results and assistant turns that carry only tool_calls with null content.

  • Text · everywhere.
  • Images · image_url parts, only on vision-capable models (see models). Everything else returns 400 model_no_vision.
  • Files · file parts with a file_data data URL. Text-like files (source code, JSON, YAML, CSV, Markdown…) are decoded and inlined as a text part, capped at 500 KB. Binary formats return 400, because upstreams reject file parts outright.

Dropped fields

response_format, logprobs, n, user, store and metadata are removed. Everything else listed above is forwarded unchanged.

Request

POST https://api.firesafety.men/v1/chat/completions

{
  "model": "oss-20b",
  "messages": [
    { "role": "system", "content": "You are terse." },
    { "role": "user", "content": "What is a race condition?" }
  ],
  "max_completion_tokens": 512,
  "temperature": 0.7,
  "stream": false
}

Response

{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "created": 1795935635,
  "model": "oss-20b",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Two processes…" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 24, "completion_tokens": 88, "total_tokens": 112 }
}

Limits enforced before dispatch

  • Unknown model → 400 unsupported_model.
  • Model not granted to your account → 403 model_not_allowed.
  • Estimated prompt + output above the context window → 400 context_length_exceeded.
  • Body above 1 MiB → rejected by the edge before it reaches the app.