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

# Chat Completions API

> Call NexusAPI text models with the OpenAI Chat Completions format.

This page covers **OpenAI Chat Completions** only. Before calling, read the [API and model capability matrix](/en/developer/capability-matrix) to confirm that the selected model and protocol match.

<Tip>
  **Use different sources for different questions**

  Use the [Apifox API reference](https://nexusapi.apifox.cn/) for full field and response schemas. Use the Model Marketplace and the capability matrix for current model availability, token-group access, and protocol selection.
</Tip>

## Endpoint

```text theme={"system"}
POST https://nexusapi.link/v1/chat/completions
```

## Minimal request

```bash theme={"system"}
curl 'https://nexusapi.link/v1/chat/completions' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'
```

## Required headers

| Header          | Required | Value                 |
| --------------- | -------- | --------------------- |
| `Content-Type`  | Yes      | `application/json`    |
| `Authorization` | Yes      | `Bearer YOUR_API_KEY` |

## Minimum fields and streaming

| Field      | Required | Purpose                                                                               |
| ---------- | -------- | ------------------------------------------------------------------------------------- |
| `model`    | Yes      | Exact model ID visible to the current key and labelled `openai`                       |
| `messages` | Yes      | Conversation messages in Chat Completions format                                      |
| `stream`   | No       | Use `true` to consume streaming events only when both the model and client support it |

For a normal response, text is usually read from `choices[0].message.content`; for a streamed response, read each `choices[0].delta.content`. Verify the model and key with the non-streaming minimum request before enabling `stream` or adding optional fields.

Optional fields such as `temperature`, tool calls, vision input, and structured output are not guaranteed for every model merely because an API is “OpenAI-compatible.” Use the [Apifox API reference](https://nexusapi.apifox.cn/) for field schemas, and the [API and model capability matrix](/en/developer/capability-matrix) plus Model Marketplace for model and channel availability.

## Common failures

| Result          | First things to check                                        |
| --------------- | ------------------------------------------------------------ |
| 401             | Missing, invalid, expired, or disabled API key.              |
| 429             | Request rate, concurrency, or temporary upstream throttling. |
| 500 / 502 / 503 | A temporary processing or upstream failure.                  |
| 524             | The request exceeded a waiting limit.                        |

If you see `status_code=500, not implemented` while calling a current Anthropic-type Claude channel through `/v1/responses`, do not retry it as a normal 500. Use `/v1/chat/completions` for a custom OpenAI-style application, or use Claude Code's native Messages configuration.

For any other error, keep the Request ID and use the [self-check guide](/en/faq/self-check). Avoid rapid retries.

## Related APIs

* List models visible to the current key and select a protocol: [API basics](/en/developer/api-basics)
* Native Claude / Anthropic client: [Anthropic Messages](/en/developer/anthropic-messages)
* Codex Provider: [Responses API and Codex](/en/developer/responses)
* Image generation: [Image model guide](/en/guide/image-generation)
