# ChatCompletions Format

Source: https://docs.aicentos.com/en/api/chat/openai/chat-completions

Language: en

Chat — native OpenAI format

`POST /chat/completions`

## Authentication

Store your API key in `AICENTOS_API_KEY`; the shell examples expand it in the `Authorization: Bearer` header.

The API Key obtained under "Token Management" in the console

Location: `header`

## Request Body

`application/json`

TypeScript type definition

Use the request body type in TypeScript

## Response Body

###

`application/json`

###

`application/json`

###

`application/json`

###

`application/json`

```bash
export AICENTOS_API_KEY="sk-your-aicentos-api-key"

curl -X POST "https://aicentos.com/v1/chat/completions" \
  -H "Authorization: Bearer $AICENTOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{    "model": "gpt-4o-mini",    "messages": [      {        "role": "user",        "content": "Introduce yourself in one sentence"      }    ]  }'
```

```bash
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "system",
        "content": "string",
        "name": "string"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
```

```bash
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

```bash
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

```bash
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```