Markdown ↗

OHGROK / Integration guide

Chat completions

Send messages and read a text response.

POST/v1/chat/completionsGet Markdown ↗
On this page

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.

Parameters

FieldTypeRequiredDescription
modelstringRequiredEnabled model ID, for example grok-4.5.
messagesarrayRequiredMessage objects with role and content.
streambooleanOptionalUse false for a single JSON response.

Request example

cURL
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
  }'

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.

Illustrative structure — not a live receipt
{"choices":[{"index":0,"message":{"role":"assistant","content":"Hello!"},"finish_reason":"stop"}]}

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.