Skip to content
Hayonix

SDKs and CLI

Use the SDK you already have

Point the OpenAI SDK (chat completions or the Responses API) or the Anthropic SDK (the Messages API) at the inference API by changing only the base URL and the key: what each shape supports and what it refuses.

The inference API answers three request shapes. Each is the shape an official SDK already speaks, so an application written for one of them runs here with two changes: the base URL and an API key of yours. Model names are this platform's catalog IDs (publisher/name, listed by GET /v1/models); another vendor's model name is answered with a plain "not served here".

Environment variables
VariableValue
API_KEYsk_… (your project API key)
API_BASE_URLhttps://api.hayonix.ai/v1
INFERENCE_BASE_URLhttps://api.hayonix.ai/v1
ShapeRouteSDKBase URL to give the SDK
Chat completionsPOST /v1/chat/completionsopenai (Python, TypeScript)the inference base URL, with /v1
ResponsesPOST /v1/responsesopenai (Python, TypeScript)the inference base URL, with /v1
MessagesPOST /v1/messagesanthropic (Python), @anthropic-ai/sdk (TypeScript)the inference host, without /v1 (the SDK adds it)

All three run on the same path underneath: the same key, the same credit check (402 when your balance cannot cover the worst case), the same per-minute request and token limits with the same rate-limit headers, the same replicas and the same per-token prices. A request is billed once, on the tokens the model reported, whichever shape it came in; usage and cost analytics show which route it came through. Fine-tuned models, shared models and dedicated endpoints work in every shape.

Chat completions

The OpenAI-compatible chat API, described in full in the inference API reference.

jq -n --arg model "$MODEL" '{
  model: $model,
  messages: [{role: "user", content: "Name one use for a GPU, in five words."}],
  max_completion_tokens: 32
}' |
curl -sS "$INFERENCE_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d @- |
jq -r '"chat: " + (.choices[0].message.content // "" | gsub("^\\s+|\\s+$"; ""))'

Responses

client.responses.create and client.responses.stream work unchanged, streaming or not, including the SDK's event helpers and responses.parse for structured output.

RESPONSE=$(jq -n --arg model "$MODEL" '{
  model: $model,
  instructions: "Answer in one short sentence.",
  input: "My favourite colour is green. What is a GPU?",
  max_output_tokens: 48
}' |
curl -sS "$INFERENCE_BASE_URL/responses" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d @-)
RESPONSE_ID=$(jq -r .id <<<"$RESPONSE")
jq -r '"responses: " + ([.output[] | select(.type == "message") | .content[].text] | join("") | gsub("^\\s+|\\s+$"; ""))' <<<"$RESPONSE"

jq -n --arg model "$MODEL" --arg prev "$RESPONSE_ID" '{
  model: $model,
  previous_response_id: $prev,
  input: "What is my favourite colour? One word.",
  max_output_tokens: 8,
  store: false
}' |
curl -sS "$INFERENCE_BASE_URL/responses" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d @- |
jq -r '"continued: " + ([.output[] | select(.type == "message") | .content[].text] | join("") | gsub("^\\s+|\\s+$"; ""))'

curl -sS -X DELETE "$INFERENCE_BASE_URL/responses/$RESPONSE_ID" \
  -H "Authorization: Bearer $API_KEY" | jq -r '"deleted: \(.id)"'

Stored responses. A response is stored for its project unless you send store: false: read it back with GET /v1/responses/{id}, list what it was asked with GET /v1/responses/{id}/input_items, continue the conversation with previous_response_id (the earlier turns are sent to the model again and billed as input tokens, as any conversation is), and delete it with DELETE /v1/responses/{id}. Stored responses are encrypted at rest, visible to their own project only, and deleted 30 days after they were created. Storing needs the stored_response:create permission (continuing needs stored_response:read): a key without it gets its answer with store: false, and one that asks for store: true explicitly is refused. A response that failed or was cut off is never stored. Responses sent as lines of a batch are never stored.

Responses
Supportedinput as text or items (message with input_text and input_image parts, function_call, function_call_output); instructions; function tools, tool_choice (none, auto, required, a function), parallel_tool_calls; text.format (text, json_object, json_schema); max_output_tokens, temperature, top_p; metadata; stream; store and previous_response_id; batches (/v1/responses as a batch endpoint)
Refused, naming the parameterreasoning and text.verbosity (reasoning-model settings); hosted tools (any tool type other than function: web search, file search, code interpreter, computer use, MCP, image generation, shell); background; conversation; reusable prompt; include; max_tool_calls; top_logprobs; truncation: auto; service tiers other than the default; item_reference, reasoning and file inputs; POST /v1/responses/{id}/cancel and /v1/responses/input_tokens; any unknown parameter
Accepted and ignoreduser, safety_identifier, prompt_cache_key, prompt_cache_retention (prompt caching is automatic here), stream_options

A response that reaches max_output_tokens is incomplete with incomplete_details.reason max_output_tokens. A stream ends with response.completed, response.incomplete or, when the model fails mid-stream, response.failed.

Messages

client.messages.create and client.messages.stream work unchanged, with your key passed as the SDK's API key (it is sent in x-api-key; Authorization: Bearer works too). Errors on this route use that API's error shape ({"type": "error", "error": {"type", "message"}, "request_id"}) and status codes, so the SDK raises its usual exceptions; request-id is set on every answer.

jq -n --arg model "$MODEL" '{
  model: $model,
  max_tokens: 48,
  system: "Answer in one short sentence.",
  messages: [{role: "user", content: "What is a GPU?"}]
}' |
curl -sS "$INFERENCE_BASE_URL/messages" \
  -H "x-api-key: $API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d @- |
jq -r '"messages: " + ([.content[] | select(.type == "text") | .text] | join("") | gsub("^\\s+|\\s+$"; "")) + " (\(.stop_reason))"'

The anthropic-version header is required (the SDKs send it). Versions 2023-06-01 and 2026-10-21 are implemented and the version is recorded with each request; any other is refused. Version 2026-10-21 (what current SDKs send) has no temperature, top_p or top_k, and refuses them as that API does; send anthropic-version: 2023-06-01 to use them. anthropic-beta headers are refused: beta features of that API are not offered.

Messages
Supportedsystem (text or text blocks) and system turns; messages with text, image (base64 or URL), tool_use and tool_result blocks; custom tools (name, description, input_schema, strict), tool_choice (auto, any, tool, none, disable_parallel_tool_use); output_config.format (JSON schema); max_tokens, stop_sequences; under 2023-06-01, temperature, top_p, top_k; metadata.user_id; stream
Refused, naming the parameterextended thinking (thinking other than {"type": "disabled"}) and output_config.effort; server tools (any tool with a type other than custom: web search, web fetch, code execution, bash, text editor, computer use, memory, tool search); MCP servers; container; context_management; document, search-result and thinking blocks; file image sources; citations; inference_geo; speed: fast; workspace_id, user_profile_id, diagnostics; token counting (/v1/messages/count_tokens: usage in every answer is the exact count); that API's message batches (use /v1/batches); any unknown parameter
Accepted and ignoredcache_control anywhere (prompt caching is automatic here, and cache_read_input_tokens reports what it saved), metadata.user_id, service_tier, speed: standard, eager_input_streaming

stop_reason is end_turn, max_tokens, tool_use or stop_sequence; on engines that do not report which stop sequence matched, a stop sequence ends the turn as end_turn with stop_sequence: null. A tool_result with is_error reaches the model prefixed Error:. usage.input_tokens excludes cached input, which is cache_read_input_tokens. A stream that fails mid-way ends with an error event.