POST /v1/chat/completions

OpenAI-compatible chat completions. Streaming (SSE), tools, JSON mode, and vision are pass-through.

Authentication

Authorization: Bearer fm_live_...

Request body

request json
{
  "model": "gpt-4o-mini",
  "messages": [
    {"role": "system", "content": "You are concise."},
    {"role": "user",   "content": "What is 2+2?"}
  ],
  "temperature": 0.2,
  "max_tokens": 64,
  "stream": false
}

Required fields

  • model — string. A model id reachable on your tier (see /v1/models) or firemission/auto to engage MoE.
  • messages — array of { role, content }. Roles: system, user, assistant, tool.

Common optional fields

  • stream — boolean. When true, response is text/event-stream.
  • temperature, top_p, max_tokens, n, stop.
  • tools, tool_choice — function calling pass-through.
  • response_format{ "type": "json_object" } for JSON mode.

Fire Mission-specific headers

  • x-fm-route: cost | speed | quality | balanced — engages MoE routing. Returned route is echoed in x-fm-moe-routed.

Response (non-streaming)

response json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1714750000,
  "model": "gpt-4o-mini",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "4"},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 18, "completion_tokens": 1, "total_tokens": 19}
}

Tool calling

tools_request json
{
  "model": "gpt-4o-mini",
  "messages": [{"role": "user", "content": "What's the weather in Paris?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"]
      }
    }
  }]
}

Errors

Errors use the standard OpenAI envelope ({ error: { message, type, code, param } }). Fire Mission codes are listed on the errors page — most common: monthly_cap_exceeded, spend_cap_exceeded, provider_blocked, security_violation, model_substitution_detected.

Try it

curl https://firemission.us/v1/chat/completions \
  -H "Authorization: Bearer fm_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "model": "gpt-4o-mini", "messages": [ {"role": "system", "content": "You are concise."}, {"role": "user", "content": "What is 2+2?"} ], "temperature": 0.2, "max_tokens": 64, "stream": false }'