# Chat completions

Send messages and read a text response.

`POST /v1/chat/completions`

<a id="authentication"></a>

## Authentication

Use Authorization: Bearer YOUR_API_KEY. The selected model must be enabled for that key’s group. JSON requests use Content-Type: application/json.

<a id="parameters"></a>

## Parameters



| Field | Type | Required | Description |
| --- | --- | --- | --- |
| model | string | Required | Enabled model ID, for example grok-4.5. |
| messages | array | Required | Message objects with role and content. |
| stream | boolean | Optional | Use false for a single JSON response. |

<a id="request"></a>

## Request example



```
export OHGROK_API_KEY='YOUR_API_KEY'

curl --fail-with-body --silent --show-error \
  'https://api.ohgrok.com/v1/chat/completions' \
  -H "Authorization: Bearer $OHGROK_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "grok-4.5",
    "messages": [
      {"role": "user", "content": "Give me three short names for a creative coding project."}
    ],
    "stream": false
  }'
```

<a id="response"></a>

## Response structure

Read choices[0].message.content. usage, when returned, records token usage. Additional parameters and input modalities are model-specific; this reference documents the minimal text request.

```
{"choices":[{"index":0,"message":{"role":"assistant","content":"Hello!"},"finish_reason":"stop"}]}
```

<a id="errors"></a>

## Error handling

Read the HTTP status together with the returned error message. Check your key and group for authentication or model-access failures. Inspect balance and upstream limits for quota/rate errors; retain task IDs on timeouts.

- [Troubleshoot a request](/docs/errors/)

