OHGROK / Integration guide
Stream a text response
Consume incremental content over a streaming response.
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
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Use a model with streaming support. |
| messages | array | Required | The same role/content messages as chat. |
| stream | boolean | Required | Set to true. |
Request example
export OHGROK_API_KEY='YOUR_API_KEY'
curl --no-buffer --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": true
}' Response structure
For an OpenAI-compatible SSE response, parse complete data: events and append choices[].delta.content when present. A network chunk is not necessarily a complete event. Finish on [DONE] or a terminal error. Usage may be absent.
Check HTTP status before reading the stream. A connection error after partial output does not mean no work was done; do not silently restart the request.
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.