Chat completions
https://api.steerwise.s3techpulse.com/v1/chat/completionsSend a conversation and get the next message. The request and response follow the OpenAI format, so the OpenAI SDKs work unchanged. Needs a key with the inference scope.
Example
curl https://api.steerwise.s3techpulse.com/v1/chat/completions \
-H "Authorization: Bearer $STEERWISE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"max_completion_tokens": 512,
"messages": [
{ "role": "user", "content": "Review this diff." }
]
}' import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.steerwise.s3techpulse.com/v1",
api_key=os.environ["STEERWISE_API_KEY"],
)
resp = client.chat.completions.create(
model="auto",
max_completion_tokens=512,
messages=[{"role": "user", "content": "Review this diff."}],
)
print(resp.model, resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.steerwise.s3techpulse.com/v1",
apiKey: process.env.STEERWISE_API_KEY,
});
const resp = await client.chat.completions.create({
model: "auto",
max_completion_tokens: 512,
messages: [{ role: "user", content: "Review this diff." }],
});
console.log(resp.model, resp.choices[0].message.content);{
"id": "chatcmpl-<x-request-id>",
"object": "chat.completion",
"created": <unix time>,
"model": "<the model that served the call>",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "<the reply>", "refusal": null },
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": <n>,
"completion_tokens": <n>,
"total_tokens": <n>,
"prompt_tokens_details": { "cached_tokens": <n> },
"completion_tokens_details": { "reasoning_tokens": <n> }
},
"system_fingerprint": null
}Request body
modelstringRequiredautoto let Steerwise pick a model per call, or a model id fromGET /v1/models.messagesarrayRequiredThe conversation. Roles
system,developer,user,assistantandtool. Leading system and developer messages become the system prompt. User and tool messages can carry images (image_url) and PDFs (file.file_data) on models that support them.streambooleanStream
chat.completion.chunkevents over server-sent events, ending withdata: [DONE]. Defaults to false.stream_optionsobjectinclude_usage: truesends a final chunk withusageand emptychoicesbefore[DONE].max_completion_tokensintegerOutput token limit, thinking included. Wins over
max_tokens. Omitted: the model’s default. The call reserves this much against your limits and wallet, so a lower limit leaves more room.max_tokensintegerOlder name for
max_completion_tokens, used only when that is absent.toolsarrayFunction tools, at most 128, each with a
name,descriptionand JSON Schemaparameters. Calls come back inmessage.tool_calls.tool_choicestring or objectnone,auto,required, or a named function. A forcing choice is a 400unsupported_valueon models without forced tool use; useautowithstricttools there.parallel_tool_callsbooleanfalseasks for at most one tool call per turn.response_formatobjecttext,json_object, orjson_schemaon models with structured outputs.reasoning_effortstringminimal,none,low,medium,high,xhighormax. On a model without effort levels it is dropped and named inx-steerwise-ignored-params.stopstring or arrayUp to 4 stop sequences. On a model without stop sequences a non-empty
stopis a 400, andautonever picks such a model for the call.temperaturenumberPassed through on models with sampling control; otherwise dropped and named in
x-steerwise-ignored-params.top_pnumberAs
temperature.userstringAn end-user id for abuse attribution, sent upstream only as an opaque hash.
safety_identifieris the same and wins when both are sent.
Response
idstringchatcmpl-followed by the request id. Quote it to support.modelstringThe model that served the call: the one Steerwise picked for
auto, or the fallback model when one served it.choicesarrayOne choice with
message(content, andtool_callswhen the model called tools) andfinish_reason:stop,length,tool_callsorcontent_filter.usageobjectprompt_tokens(cached and cache-written tokens included),completion_tokens(thinking included),total_tokens,prompt_tokens_details.cached_tokensandcompletion_tokens_details.reasoning_tokens.
Response headers
x-request-id: the request id, on every response, errors included.x-steerwise-routed-from: set whenmodelwasauto.x-steerwise-fallback-from: set when a fallback model served the call; the value is the model you asked for. Never sent forauto.x-steerwise-ignored-params: parameters that were accepted but dropped.x-steerwise-run: the agent run the call belongs to, when it is known.x-ratelimit-remaining-requestsand the rest of the rate limit headers: see Rate limits.
Streaming
With "stream": true each event is data: <chunk>. The first chunk carries the role, then text arrives in delta.content; tool calls arrive in delta.tool_calls, their arguments in pieces. The last content chunk has a finish_reason, and the stream ends with data: [DONE].
: pingcomment lines arrive every 15 seconds while the model is quiet. SSE clients ignore them.- The status line waits up to 5 seconds for the model to start, so most failures still arrive as a normal error status. After the stream opens, a failure arrives as one
data: {"error": …}event and the stream closes without[DONE]. - Thinking is never returned on this endpoint, but it counts toward the output limit: a very small limit can end with
finish_reason: lengthand empty content.
Parameter policy
Unknown fields are ignored, so newer SDK fields do not break requests. Known fields that Steerwise cannot honour follow a fixed policy:
Rejected
The request fails with 400 unsupported_parameter and param names the field, because ignoring it would change the result.
n: when greater than 1logprobs: when truetop_logprobs: when setlogit_bias: when not emptyaudio: audio output is not supportedmodalities: unless it is only["text"]web_search_options: alwaysfunctions: legacy; usetoolsfunction_call: legacy; usetool_choiceprediction: always
Ignored
Accepted and dropped silently.
seed:store: nothing is storedmetadata:service_tier:prompt_cache_key: prompt caching is automatic and scoped to your organisationverbosity:
Dropped and named
Accepted, dropped and named in the x-steerwise-ignored-params response header.
presence_penalty: when not zerofrequency_penalty: when not zero
Errors
Errors use the OpenAI shape, {"error": {"message", "type", "code", "param"}}, so the OpenAI SDKs raise their usual exceptions. Branch on code.
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The body is malformed, a field is missing or invalid, or the model rejected the request (the message then starts with “Upstream rejected the request”). |
| 400 | unsupported_parameter | A parameter this API rejects (see the parameter policy on each API page), or a file part with file_id. |
| 400 | unsupported_value | A value this API or the chosen model cannot honour: for example a forced tool_choice on a model without forced tool use, an image for a model without vision, or an effort level the model lacks. |
| 400 | context_length_exceeded | The prompt is over your plan’s or key’s context limit. |
| 401 | missing_api_key | No key was sent. |
| 401 | invalid_api_key | The key is malformed, unknown, revoked or expired. |
| 402 | insufficient_balance | The wallet balance is too low for this request. |
| 402 | spend_cap_reached | Spend has reached a daily or monthly cap of the key or the organisation, or the agent run’s cap. |
| 402 | request_cost_cap_exceeded | This request’s worst case (the model, the prompt and the full output limit) is over the per-request cap. |
| 403 | account_suspended | The organisation or user is suspended. |
| 403 | wallet_frozen | Staff have put the organisation’s wallet on hold. |
| 403 | key_paused | The key is paused, usually by the runaway-spend detector after its spend jumped far past its usual rate. |
| 403 | missing_scope | The key lacks the scope this endpoint needs. |
| 403 | model_not_allowed | Your plan does not include the model. |
| 403 | model_not_allowed_for_key | The key’s allowed models exclude this model. |
| 404 | model_not_found | No active model has that id. |
| 413 | request_too_large | The body is over 32 MiB, or the model rejected the request as too large. |
| 429 | rate_limit_exceeded | A per-minute request or token limit, or the limit on calls at once, of the organisation, user, key or model. |
| 429 | insufficient_quota | The monthly token quota cannot cover this call’s reservation. |
| 429 | spend_cap_pending | Calls still in flight could reach a spend cap. |
| 500 | internal_error | Something failed on our side. Details are logged under the request id, never returned. |
| 502 | upstream_error | The model failed after retries and fallback. |
| 503 | upstream_overloaded | The model was overloaded or unavailable after retries and fallback, or Steerwise is holding back calls to it. |
| 503 | wallet_unavailable | The balance check could not run, so the request was not started. |
| 503 | limits_unavailable | The rate-limit check could not run, so the request was not started. |
| 503 | server_overloaded | The server is at its limit of requests at once. |
| 503 | service_unavailable | The key could not be checked in time. With x-should-retry: false and no Retry-After: no model that could serve the call is available right now. |
| 503 | service_restarting | The server is restarting and cancelled the request. |
| 504 | upstream_timeout | The model did not start, or went quiet for too long, after retries and fallback. |
What to do about each one: Errors and limits.
Every field and schema: Full API reference.