Quickstart
Make your first request in under a minute.
Create a key
Sign in at opinference.com, add credit under Billing, then create a Live key under API Keys. The key is shown once. Copy it and export it:
export OP_API_KEY="op_live_..."Send a request
The API speaks the OpenAI chat completions format, so the OpenAI SDK works with a different base URL.
curl https://api.opinference.com/v1/chat/completions \
-H "Authorization: Bearer $OP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-120b",
"messages": [{"role": "user", "content": "Say hello."}]
}'Stream the reply
Set stream to true to receive the reply as it is generated.
curl -N https://api.opinference.com/v1/chat/completions \
-H "Authorization: Bearer $OP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-120b",
"messages": [{"role": "user", "content": "Say hello."}],
"stream": true
}'The last chunk carries usage. It can arrive with an empty choices array, which is why the
loops above check before reading choices[0].
Next
- Pick a model on the models page. Each model's page lists its price and, for media models, the inputs it accepts.
- Generate an image: How media jobs work.
- Handle failures: Errors.