Skip to main content
Use this endpoint for clients that expect the OpenAI Chat Completions format. The examples below cover text requests. Compatibility does not imply every upstream feature is available.

1. Set your API key

Create an API key and add balance in the AsterWise app. In your terminal, replace the placeholder:

2. Send a request

POST https://api.asterwise.dev/v1/chat/completions
--include displays response headers as well as the body. Omit it if you want only JSON. Keep your API key private.

Request fields

The example cap of 1,024 tokens limits this response’s length. It is not the model’s maximum context window or a rate limit. max_tokens is also accepted as an alternative output cap. Do not send it together with max_completion_tokens.

Generation controls

reasoning_effort is the documented effort selector here. A route-specific reasoning object is also recognized, but is not a universal enable/budget/exclude schema. Do not substitute Responses reasoning.effort or Messages thinking / output_config for this example. For defaults, unavailable controls, tool-choice restrictions, and the DeepSeek sampling no-op exception, see parameters and model compatibility.

Reasoning and tool example

Use this JSON body with the endpoint and authentication headers above. It illustrates the supported request shape; it is not a new live-provider acceptance result. Automatic tool selection allows the model to answer without calling the tool.
Your application executes get_build_status when requested. Append the assistant tool-call message and a role: "tool" message with the matching tool_call_id to messages before the next request.

3. Read the response

Illustrative text-only response, checked against AsterWise’s response handling. IDs, answer text, and token counts below are examples, not a captured production request. Additional fields may be present.
For a text reply, read choices[0].message.content. Inspect finish_reason as well: stop indicates normal completion, while a length limit can produce a truncated answer. A tool request can contain message.tool_calls instead of ordinary answer text. Here, prompt_tokens means input tokens and completion_tokens means output tokens. The usage object contains counts, not a dollar charge.

Streaming

Change "stream": false to "stream": true in the request above and add --no-buffer to curl. Read the response as server-sent events (SSE), not as one JSON document. The following is an abbreviated example:
Append text from choices[].delta.content. These are incremental pieces, not complete messages. Check the finish reason and stream termination. Usage may arrive in a separate chunk, including one with an empty choices array.

Errors

Gateway authentication and request-validation errors before streaming starts use an HTTP error status and the JSON format below. Malformed JSON, oversized bodies, or proxy errors can have a different response format; check the status and content type before parsing. For example, an invalid key returns 401:
This is AsterWise’s shared gateway error format, including on the OpenAI-compatible endpoints. Handle error.type rather than assuming an upstream error schema. AsterWise currently has no per-minute request or token rate limits. A 429 can still indicate a spending or simultaneous-request control. Once an SSE stream has started, an error may arrive as an error event rather than a new HTTP status. Do not treat HTTP 200 alone as a completed response. Save the x-request-id response header when present, and check Usage if the connection ends unexpectedly. See troubleshooting and usage and billing.