# Chat Completions

> Use the OpenAI-compatible Chat Completions interface through LLMoxy.

`POST /v1/chat/completions` is the main OpenAI-compatible chat endpoint.

```bash
curl https://llmoxy.com/v1/chat/completions \
  -H "Authorization: Bearer <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.7",
    "messages": [
      { "role": "system", "content": "Be concise." },
      { "role": "user", "content": "What is LLMoxy?" }
    ]
  }'
```

## Request Body

Common fields:

| Field | Description |
| --- | --- |
| `model` | Required. Model ID. |
| `messages` | Required. Array of conversation messages. |
| `temperature`, `top_p`, `n`, `stop` | Sampling control parameters, passed to compatible upstreams. |
| `max_tokens`, `max_completion_tokens` | Output token limits. |
| `stream` | Set to `true` to enable SSE streaming. |
| `stream_options.include_usage` | Returns usage in streaming responses when supported by upstream. |
| `tools`, `tool_choice` | OpenAI-compatible tool calling. |
| `response_format` | Request structured output for supported models. |
| `reasoning_effort` | Supported reasoning models can use `low`, `medium`, `high`. |
| `modalities`, `audio` | Available for models that support multimodal audio. |
| `user` | Optional. For your own end-user identification. |

Different models support different parameters. If the response says a parameter is unsupported, remove it or switch to another model.

## Streaming Output

```json
{
  "model": "grok-4.7",
  "stream": true,
  "messages": [
    { "role": "user", "content": "Stream one sentence." }
  ]
}
```

Responses use OpenAI-style SSE chunks and end with `[DONE]`.

## Tool Calling

```json
{
  "model": "grok-4.7",
  "messages": [
    { "role": "user", "content": "What is the weather in Singapore?" }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    }
  ]
}
```

Models that support tool calling receive tool definitions and return OpenAI-compatible tool call responses.

## Legacy Completions

Legacy text completion clients can use `POST /v1/completions`.

This is the markdown version of https://en.llmoxy.com/docs/api-reference/chat-completions.
