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

# Chat completions

> Send conversation history and read the assistant's response.

`POST /v1/chat/completions` accepts OpenAI-style messages. Provide a model ID and a non-empty `messages` array. Keep conversation history in your application and send the messages needed for each turn.

```javascript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LIMITLESS_API_KEY,
  baseURL: process.env.LIMITLESS_BASE_URL,
  maxRetries: 0,
});

const messages = [
  { role: "system", content: "Answer briefly and identify uncertainty." },
  { role: "user", content: "What does a language model's context window mean?" },
];

const result = await client.chat.completions.create({
  model: process.env.LIMITLESS_MODEL,
  messages,
  max_tokens: 512,
});

const answer = result.choices[0]?.message;
console.log(answer?.content);
console.log(result.choices[0]?.finish_reason);
```

## Request settings

| Field | Use |
| - | - |
| `model` | Model ID from the catalog. Required. |
| `messages` | Conversation in order. Required and non-empty. |
| `max_tokens` or `max_completion_tokens` | Output bound supported by the chosen model. Send one. |
| `temperature` | Sampling setting, if supported by the model. |
| `stream` | Set to `true` for server-sent events. |
| `tools`, `tool_choice` | Function definitions and selection behavior, if supported. |
| `web_search_options` | Hosted search; do not combine with a non-empty function tools array. |
| `n` | Number of completions, from 1 to 128. All returned choices contribute to usage. |
| `reasoning_effort`, `reasoning` | Model-specific reasoning controls. |
| `policy_ids` | Additional published Limitless policy IDs. |
| `response_format` | Structured-output request, if supported. |

Unsupported provider parameters can return `400`. Passing a parameter through the gateway does not guarantee model support. See [compatibility](/guides/compatibility).

## Read the result

`choices[0].message.content` contains text when the model returns text. A tool call can instead appear in `choices[0].message.tool_calls`.

Inspect `finish_reason`. A response stopped at the output limit may be incomplete. Some models consume output capacity on reasoning before returning visible text; an empty text field does not necessarily imply zero usage.

When reported, `usage.prompt_tokens` and `usage.completion_tokens` contain the provider's token counts. Use [Activity](/usage) for the durable request record.

## Continue the conversation

Append the assistant message and your next user message to the history, then make another request. Each request is independently metered and charged using its recorded token usage. Prior messages count toward the next request's input.

For streaming, follow the [streaming guide](/guides/streaming).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.