# Format ChatCompletions

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

Language: fr

Chat — format natif OpenAI

`POST /chat/completions`

## Authentification

Stockez votre clé API dans `AICENTOS_API_KEY` ; les exemples shell utilisent sa valeur dans l’en-tête `Authorization: Bearer`.

Clé API obtenue dans la console, section « Gestion des jetons »

Emplacement : `header`

## Corps de requête

`application/json`

Définition des types TypeScript

Utiliser le type de corps de requête dans TypeScript

## Corps de réponse

###

`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": "Présente-toi en une phrase"      }    ]  }'
```

```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"
  }
}
```