> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/chat/completions — OpenAI chat format

> Send a conversation history to any model and receive a completion. Anyone is fully compatible with the OpenAI Chat Completions API format.

The `/v1/chat/completions` endpoint accepts a list of messages and returns the model's reply. Because Anyone implements the OpenAI Chat Completions format exactly, you can point any existing OpenAI SDK or client at Anyone by changing only the base URL and API key — no other code changes are required. Anyone authenticates with the API key you created in the dashboard, and routes the request to whichever upstream channel is configured for the model you requested.

## Endpoint

```
POST /v1/chat/completions
```

## Authentication

Pass your Anyone API key as a Bearer token in the `Authorization` header:

```
Authorization: Bearer YOUR_TOKEN
```

## Request parameters

<ParamField body="model" type="string" required>
  The model identifier to use for the completion. Anyone routes the request to the configured upstream channel for this model.

  For reasoning effort on OpenAI o-series models, use suffix variants: `o3-mini-high`, `o3-mini-medium`, or `o3-mini-low`. These map to `reasoning_effort` values of `high`, `medium`, and `low` respectively.
</ParamField>

<ParamField body="messages" type="object[]" required>
  The conversation history as an ordered array of messages. Each message must include a `role` and `content`.

  <Expandable title="message properties">
    <ParamField body="messages[].role" type="string" required>
      The role of the message author. One of `system`, `user`, `assistant`, or `tool`. For newer OpenAI reasoning models (o3 and later, gpt-5 and later), use `developer` instead of `system`.
    </ParamField>

    <ParamField body="messages[].content" type="string | object[]" required>
      The message content. Pass a plain string for text-only messages. Pass an array of content parts for multimodal messages (text, images, audio, files).
    </ParamField>

    <ParamField body="messages[].name" type="string">
      An optional name for the participant. Useful when the same role appears multiple times.
    </ParamField>

    <ParamField body="messages[].tool_calls" type="object[]">
      Tool calls generated by the model in a previous turn. Present only on `assistant` messages that invoked tools.
    </ParamField>

    <ParamField body="messages[].tool_call_id" type="string">
      The ID of the tool call this message is responding to. Required on `tool` role messages.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  When `true`, the response is returned as a stream of server-sent events (SSE). Each event contains a partial `ChatCompletionChunk` object. The stream ends with a `data: [DONE]` line.
</ParamField>

<ParamField body="stream_options" type="object">
  Options that apply only when `stream` is `true`.

  <Expandable title="stream_options properties">
    <ParamField body="stream_options.include_usage" type="boolean" default="false">
      When `true`, the final SSE chunk includes a `usage` field with token counts.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature between `0` and `2`. Higher values produce more random output; lower values produce more deterministic output. Mutually exclusive with `top_p` — use one or the other, not both.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling probability mass. The model considers only the API keys whose cumulative probability is at least `top_p`. Values between `0` and `1`. Mutually exclusive with `temperature`.
</ParamField>

<ParamField body="max_tokens" type="integer">
  The maximum number of tokens the model may generate. If omitted, the model's default limit applies. Use `max_completion_tokens` for newer OpenAI models.
</ParamField>

<ParamField body="max_completion_tokens" type="integer">
  The maximum number of tokens to generate in the completion, including reasoning tokens. Takes precedence over `max_tokens` when both are provided.
</ParamField>

<ParamField body="reasoning_effort" type="string">
  Controls how much reasoning the model performs before responding. Accepted values: `low`, `medium`, `high`. Applies to OpenAI reasoning models (o-series). As an alternative, you can encode effort in the model name directly: `o3-mini-high`, `o3-mini-medium`, `o3-mini-low`.
</ParamField>

<ParamField body="stop" type="string | string[]">
  One or more sequences at which the model stops generating. The model output will not include the stop sequence itself.
</ParamField>

<ParamField body="n" type="integer" default="1">
  How many completion choices to generate for each message.
</ParamField>

<ParamField body="frequency_penalty" type="number" default="0">
  Number between `-2.0` and `2.0`. Positive values penalize tokens that appear frequently in the text so far, reducing repetition.
</ParamField>

<ParamField body="presence_penalty" type="number" default="0">
  Number between `-2.0` and `2.0`. Positive values penalize tokens that have appeared at all in the text so far, increasing topic diversity.
</ParamField>

<ParamField body="seed" type="integer">
  When set, the model attempts to produce deterministic output. Reproducibility is not guaranteed across model versions.
</ParamField>

<ParamField body="logprobs" type="boolean" default="false">
  Whether to return log probabilities of the output tokens.
</ParamField>

<ParamField body="top_logprobs" type="integer">
  The number of most likely tokens to return at each API key position, along with their log probabilities. Requires `logprobs` to be `true`. Between `0` and `20`.
</ParamField>

<ParamField body="tools" type="object[]">
  A list of tools the model may call. Each tool defines a function the model can invoke.

  <Expandable title="tool properties">
    <ParamField body="tools[].type" type="string" required>
      The type of tool. Currently only `"function"` is supported.
    </ParamField>

    <ParamField body="tools[].function" type="object" required>
      The function definition.

      <Expandable title="function properties">
        <ParamField body="tools[].function.name" type="string" required>
          The name of the function to call.
        </ParamField>

        <ParamField body="tools[].function.description" type="string">
          A description of what the function does. The model uses this to decide when to call it.
        </ParamField>

        <ParamField body="tools[].function.parameters" type="object">
          The function's parameters in JSON Schema format.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="tool_choice" type="string | object" default="auto">
  Controls how the model selects which tool to call. Pass `"none"` to disable tool calls, `"auto"` to let the model decide, `"required"` to force a tool call, or an object `{"type": "function", "function": {"name": "..."}}` to force a specific function.
</ParamField>

<ParamField body="parallel_tool_calls" type="boolean" default="true">
  Whether the model may call multiple tools in a single turn.
</ParamField>

<ParamField body="response_format" type="object">
  Specifies the output format. Pass `{"type": "json_object"}` to enable JSON mode. Pass `{"type": "json_schema", "json_schema": {...}}` to enforce a specific JSON Schema.

  <Expandable title="response_format properties">
    <ParamField body="response_format.type" type="string" required>
      Output format. One of `"text"`, `"json_object"`, or `"json_schema"`.
    </ParamField>

    <ParamField body="response_format.json_schema" type="object">
      Required when `type` is `"json_schema"`. Defines the schema the output must conform to.
    </ParamField>
  </Expandable>
</ParamField>

## Response fields

<ResponseField name="id" type="string">
  A unique identifier for this completion in the format `chatcmpl-...`.
</ResponseField>

<ResponseField name="object" type="string">
  Always `"chat.completion"` for non-streaming responses, or `"chat.completion.chunk"` for streaming chunks.
</ResponseField>

<ResponseField name="created" type="integer">
  Unix timestamp (seconds) of when the completion was created.
</ResponseField>

<ResponseField name="model" type="string">
  The model identifier that was used to generate this completion.
</ResponseField>

<ResponseField name="choices" type="object[]">
  An array of completion choices. Most requests return one choice (`n=1`).

  <Expandable title="choice properties">
    <ResponseField name="choices[].index" type="integer">
      The index of this choice, starting from `0`.
    </ResponseField>

    <ResponseField name="choices[].message" type="object">
      The generated message.

      <Expandable title="message properties">
        <ResponseField name="choices[].message.role" type="string">
          Always `"assistant"` for generated messages.
        </ResponseField>

        <ResponseField name="choices[].message.content" type="string | null">
          The text content of the message. `null` when the model called a tool instead of generating text.
        </ResponseField>

        <ResponseField name="choices[].message.tool_calls" type="object[]">
          Tool calls the model wants to make, if any. Each entry has `id`, `type`, and `function` (with `name` and `arguments`).
        </ResponseField>

        <ResponseField name="choices[].message.reasoning_content" type="string">
          The model's internal reasoning, when the upstream returns it (e.g. from thinking-capable models).
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="choices[].finish_reason" type="string">
      Why the model stopped generating. One of `"stop"` (natural end), `"length"` (token limit), `"tool_calls"` (tool invoked), or `"content_filter"`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usage" type="object">
  Token counts for this request.

  <Expandable title="usage properties">
    <ResponseField name="usage.prompt_tokens" type="integer">
      Number of tokens in the input messages.
    </ResponseField>

    <ResponseField name="usage.completion_tokens" type="integer">
      Number of tokens in the generated output.
    </ResponseField>

    <ResponseField name="usage.total_tokens" type="integer">
      Sum of `prompt_tokens` and `completion_tokens`.
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<Tabs>
  <Tab title="Non-streaming">
    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.anyone.ai/v1/chat/completions \
        -H "Authorization: Bearer YOUR_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "gpt-5.4",
          "messages": [
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "What is the capital of France?"}
          ]
        }'
      ```

      ```python Python (openai SDK) theme={null}
      from openai import OpenAI

      client = OpenAI(
          api_key="YOUR_TOKEN",
          base_url="https://api.anyone.ai/v1",
      )

      response = client.chat.completions.create(
          model="gpt-5.4",
          messages=[
              {"role": "system", "content": "You are a helpful assistant."},
              {"role": "user", "content": "What is the capital of France?"},
          ],
      )

      print(response.choices[0].message.content)
      ```

      ```javascript JavaScript (openai SDK) theme={null}
      import OpenAI from "openai";

      const client = new OpenAI({
        apiKey: "YOUR_TOKEN",
        baseURL: "https://api.anyone.ai/v1",
      });

      const response = await client.chat.completions.create({
        model: "gpt-5.4",
        messages: [
          { role: "system", content: "You are a helpful assistant." },
          { role: "user", content: "What is the capital of France?" },
        ],
      });

      console.log(response.choices[0].message.content);
      ```
    </CodeGroup>

    **Example response:**

    ```json theme={null}
    {
      "id": "chatcmpl-abc123",
      "object": "chat.completion",
      "created": 1714000000,
      "model": "gpt-5.4",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "The capital of France is Paris."
          },
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 25,
        "completion_tokens": 9,
        "total_tokens": 34
      }
    }
    ```
  </Tab>

  <Tab title="Streaming">
    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.anyone.ai/v1/chat/completions \
        -H "Authorization: Bearer YOUR_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "gpt-5.4",
          "stream": true,
          "stream_options": {"include_usage": true},
          "messages": [
            {"role": "user", "content": "Tell me a short joke."}
          ]
        }'
      ```

      ```python Python (openai SDK) theme={null}
      from openai import OpenAI

      client = OpenAI(
          api_key="YOUR_TOKEN",
          base_url="https://api.anyone.ai/v1",
      )

      stream = client.chat.completions.create(
          model="gpt-5.4",
          stream=True,
          messages=[
              {"role": "user", "content": "Tell me a short joke."},
          ],
      )

      for chunk in stream:
          delta = chunk.choices[0].delta
          if delta.content:
              print(delta.content, end="", flush=True)
      ```

      ```javascript JavaScript (openai SDK) theme={null}
      import OpenAI from "openai";

      const client = new OpenAI({
        apiKey: "YOUR_TOKEN",
        baseURL: "https://api.anyone.ai/v1",
      });

      const stream = await client.chat.completions.create({
        model: "gpt-5.4",
        stream: true,
        messages: [{ role: "user", content: "Tell me a short joke." }],
      });

      for await (const chunk of stream) {
        const delta = chunk.choices[0]?.delta;
        if (delta?.content) process.stdout.write(delta.content);
      }
      ```
    </CodeGroup>

    The server sends events in the following format. Each line begins with `data: ` followed by a JSON object:

    ```
    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1714000000,"model":"gpt-5.4","choices":[{"index":0,"delta":{"role":"assistant","content":"Why"},"finish_reason":null}]}

    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1714000000,"model":"gpt-5.4","choices":[{"index":0,"delta":{"content":" don't"},"finish_reason":null}]}

    data: [DONE]
    ```
  </Tab>
</Tabs>

## Reasoning models

To use OpenAI reasoning models, set `model` to an o-series identifier. You can control reasoning effort either with the `reasoning_effort` parameter or by encoding effort directly in the model name:

```json theme={null}
{"model": "o3-mini-high", "messages": [...]}
```

is equivalent to:

```json theme={null}
{"model": "o3-mini", "reasoning_effort": "high", "messages": [...]}
```

For Claude thinking mode, use the `-thinking` suffix model name — for example, `claude-sonnet-4-6-thinking`. For Gemini thinking, append `-thinking` to any Gemini model name, or use `-low`, `-medium`, or `-high` for effort control.
