Skip to main content
POST
Create chat completion

Authorizations

Authorization
string
header
required

API key in the Authorization header: Bearer sk_hopper_... Keys are minted in the dashboard at withhopper.com/console/keys and shown once at creation. WebSocket connections also accept ?api_key=.

Body

application/json

Passed through to the inference engine. Fields below are the common subset; any other OpenAI chat completions parameter is also accepted.

model
string
required

Model id, e.g. gemma-4-31b.

messages
object[]
required

OpenAI chat messages.

stream
boolean
default:false

Stream tokens as SSE chunks.

temperature
number

Sampling temperature; passed through.

max_tokens
integer

Maximum output tokens; passed through.

tools
object[]

OpenAI tool definitions; passed through.

stream_options
object

Set include_usage true to receive a final usage chunk. The gateway meters usage either way.

Response

Non-streaming: an OpenAI chat completion object with both spend headers. Streaming: text/event-stream of OpenAI chunks, with only x-hopper-credits-remaining-usd (the pre-request balance; cost is unknown until the stream ends).

OpenAI chat completion object, forwarded from the inference engine.