Markdown ↗

OHGROK / Integration guide

Make your first API request

Set your base URL, add an API key, and send a text request.

On this page

Before the request

Start with a small text request. The same account and familiar HTTP interface connect your application to the models available in your selected group.

Registration is open. Sign in or create an account, check the current wallet options and balance, and create a key with access to the selected model group.

1. Choose the right model group

Sign in to the console and open API keys. Create a key in an enabled group that lists grok-4.5, such as 重度方案|Grok Heavy (channel2-grok-heavy). The group attached to the key controls routing and price.

  1. Check the model detail page for current access and rates.
  2. A default-group key does not automatically gain access to every model-specific group.
  3. Keep the key on your server or in your local environment, rather than in a public browser bundle.

2. Send a small request

Use a terminal with curl installed. Replace YOUR_API_KEY with your own site API key, then run the request below. It asks for a short response and returns JSON.

Terminal · 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
  }'

3. Read the result

On a successful chat-completions response, read the answer from choices[0].message.content. Inspect the returned usage when present, and use the console records to review the request.

If you use an OpenAI-compatible SDK, set its base URL to https://api.ohgrok.com/v1 and pass the same key and exact model ID. Use the actual method supported by your SDK; no special ohgrok SDK is required.

For token-priced text models, separate uncached input, cache reads, five-minute cache writes, one-hour cache writes and output into non-overlapping buckets. Track full input length per request; context thresholds and rates can differ by model group. Per-request models use request counts instead.

For cache-write estimates, select the usage format recorded for the request. OpenAI-format usage combines writes; Anthropic-format usage separates the two write durations. A missing write rate does not automatically mean the same cost in both formats. Check the calculator’s selected format before comparing estimates.

A model being listed does not guarantee available upstream capacity. Limits, available groups, and account balance still apply to each request.

4. If the request returns an error

Keep the HTTP status and returned error message together when diagnosing a request.

  1. Authentication error: check the site API key and Authorization header.
  2. Model or group error: check the exact model ID and the group selected when creating the key.
  3. Quota or rate-limit error: check account access and the upstream limit reported in the response.
  4. Upstream error: retain the request details and retry deliberately; avoid an unbounded automatic retry loop.