Docs pages

Chat completions

POSThttps://api.steerwise.s3techpulse.com/v1/chat/completions

Send 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

Code samples in
bashpythonjavascript
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);
Example response (json, 200)
{
  "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

  • modelstringRequired

    auto to let Steerwise pick a model per call, or a model id from GET /v1/models.

  • messagesarrayRequired

    The conversation. Roles system, developer, user, assistant and tool. 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.

  • streamboolean

    Stream chat.completion.chunk events over server-sent events, ending with data: [DONE]. Defaults to false.

  • stream_optionsobject

    include_usage: true sends a final chunk with usage and empty choices before [DONE].

  • max_completion_tokensinteger

    Output 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_tokensinteger

    Older name for max_completion_tokens, used only when that is absent.

  • toolsarray

    Function tools, at most 128, each with a name, description and JSON Schema parameters. Calls come back in message.tool_calls.

  • tool_choicestring or object

    none, auto, required, or a named function. A forcing choice is a 400 unsupported_value on models without forced tool use; use auto with strict tools there.

  • parallel_tool_callsboolean

    false asks for at most one tool call per turn.

  • response_formatobject

    text, json_object, or json_schema on models with structured outputs.

  • reasoning_effortstring

    minimal, none, low, medium, high, xhigh or max. On a model without effort levels it is dropped and named in x-steerwise-ignored-params.

  • stopstring or array

    Up to 4 stop sequences. On a model without stop sequences a non-empty stop is a 400, and auto never picks such a model for the call.

  • temperaturenumber

    Passed through on models with sampling control; otherwise dropped and named in x-steerwise-ignored-params.

  • top_pnumber

    As temperature.

  • userstring

    An end-user id for abuse attribution, sent upstream only as an opaque hash. safety_identifier is the same and wins when both are sent.

Response

  • idstring

    chatcmpl- followed by the request id. Quote it to support.

  • modelstring

    The model that served the call: the one Steerwise picked for auto, or the fallback model when one served it.

  • choicesarray

    One choice with message (content, and tool_calls when the model called tools) and finish_reason: stop, length, tool_calls or content_filter.

  • usageobject

    prompt_tokens (cached and cache-written tokens included), completion_tokens (thinking included), total_tokens, prompt_tokens_details.cached_tokens and completion_tokens_details.reasoning_tokens.

Response headers

  • x-request-id: the request id, on every response, errors included.
  • x-steerwise-routed-from: set when model was auto.
  • x-steerwise-fallback-from: set when a fallback model served the call; the value is the model you asked for. Never sent for auto.
  • 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-requests and 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].

  • : ping comment 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: length and 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 1
  • logprobs: when true
  • top_logprobs: when set
  • logit_bias: when not empty
  • audio: audio output is not supported
  • modalities: unless it is only ["text"]
  • web_search_options: always
  • functions: legacy; use tools
  • function_call: legacy; use tool_choice
  • prediction: always

Ignored

Accepted and dropped silently.

  • seed:
  • store: nothing is stored
  • metadata:
  • service_tier:
  • prompt_cache_key: prompt caching is automatic and scoped to your organisation
  • verbosity:

Dropped and named

Accepted, dropped and named in the x-steerwise-ignored-params response header.

  • presence_penalty: when not zero
  • frequency_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.

Errors for this endpoint
StatusCodeWhen
400invalid_requestThe body is malformed, a field is missing or invalid, or the model rejected the request (the message then starts with “Upstream rejected the request”).
400unsupported_parameterA parameter this API rejects (see the parameter policy on each API page), or a file part with file_id.
400unsupported_valueA 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.
400context_length_exceededThe prompt is over your plan’s or key’s context limit.
401missing_api_keyNo key was sent.
401invalid_api_keyThe key is malformed, unknown, revoked or expired.
402insufficient_balanceThe wallet balance is too low for this request.
402spend_cap_reachedSpend has reached a daily or monthly cap of the key or the organisation, or the agent run’s cap.
402request_cost_cap_exceededThis request’s worst case (the model, the prompt and the full output limit) is over the per-request cap.
403account_suspendedThe organisation or user is suspended.
403wallet_frozenStaff have put the organisation’s wallet on hold.
403key_pausedThe key is paused, usually by the runaway-spend detector after its spend jumped far past its usual rate.
403missing_scopeThe key lacks the scope this endpoint needs.
403model_not_allowedYour plan does not include the model.
403model_not_allowed_for_keyThe key’s allowed models exclude this model.
404model_not_foundNo active model has that id.
413request_too_largeThe body is over 32 MiB, or the model rejected the request as too large.
429rate_limit_exceededA per-minute request or token limit, or the limit on calls at once, of the organisation, user, key or model.
429insufficient_quotaThe monthly token quota cannot cover this call’s reservation.
429spend_cap_pendingCalls still in flight could reach a spend cap.
500internal_errorSomething failed on our side. Details are logged under the request id, never returned.
502upstream_errorThe model failed after retries and fallback.
503upstream_overloadedThe model was overloaded or unavailable after retries and fallback, or Steerwise is holding back calls to it.
503wallet_unavailableThe balance check could not run, so the request was not started.
503limits_unavailableThe rate-limit check could not run, so the request was not started.
503server_overloadedThe server is at its limit of requests at once.
503service_unavailableThe 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.
503service_restartingThe server is restarting and cancelled the request.
504upstream_timeoutThe model did not start, or went quiet for too long, after retries and fallback.

What to do about each one: Errors and limits.