Skip to content
This is the public test network documentation. Everything here runs on Avalanche Fuji with test USDC.

Create a chat completion

POST
/chat/completions
curl --request POST \
--url https://api.staging.katara.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "katara/llama-3.1-8b-instruct@1", "messages": [ { "role": "user", "content": "Explain a Merkle tree in two sentences." } ], "max_tokens": 200 }'

Same request body as OpenAI chat completions. Set stream: true for server-sent events.

The reply carries a katara object with what you were charged and who served you. In a stream it arrives as one final chunk with an empty choices array, after the content and before data: [DONE].

Admission is checked before any work starts: the balance behind the key must cover the maximum this request could cost (input estimate plus max_tokens at the offer price). Otherwise the request is refused with insufficient_quota and nothing is charged.

Media typeapplication/json
object
model
required
string
messages
required
Array<object>
object
role
required
string
Allowed values: system user assistant tool
content
required
Any of:
string
name
string
tool_call_id
string
stream
boolean
max_tokens

Bounds the output and therefore the maximum charge.

integer
temperature
number
top_p
number
tools
Array<object>
object
tool_choice
response_format
object
stop
Example
{
"model": "katara/llama-3.1-8b-instruct@1",
"messages": [
{
"role": "user",
"content": "Explain a Merkle tree in two sentences."
}
],
"max_tokens": 200
}

The completion, or a server-sent event stream when stream is true.

object
id
required
string
object
required
string
Allowed value: chat.completion
model
required
string
system_fingerprint

Who served the request. <bundle>:<profile> for a named model, cortex:<model> for a reply routed by katara/cortex@1.

string
choices
required
Array<object>
object
index
integer
finish_reason
string
Allowed values: stop length tool_calls content_filter
message
object
role
string
content

Null when the reply is tool calls only.

string | null
tool_calls

Validated calls. Every entry has an id, a non-empty name and arguments that parse as a JSON object.

Array<object>
object
id
string
type
string
Allowed value: function
function
object
name
string
arguments

A JSON object document.

string
usage
required
object
prompt_tokens
integer
completion_tokens
integer
total_tokens
integer
katara
required

What this reply cost and who produced it.

object
cost_usdc
required

The settled price, in USDC, as a decimal string.

string
provider
required

The provider’s address, or managed when a vendor answered through katara/cortex@1.

string
served

Present on replies routed by katara/cortex@1. The concrete model behind the reply.

object
model
string
bundleId
string
provider

The address that served, or the managed identity.

string
managed

True when a vendor answered because no marketplace provider could.

boolean
reason

available, failover:<n> after n models failed before delivering, or managed:<why>.

string
Example
{
"id": "chatcmpl-7f3a9c2e1b0d",
"object": "chat.completion",
"model": "katara/llama-3.1-8b-instruct@1",
"system_fingerprint": "0xb353…:0x620b…",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "A Merkle tree hashes data in pairs up to one root hash…"
}
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 52,
"total_tokens": 70
},
"katara": {
"cost_usdc": "0.000018",
"provider": "0xfFe5…38DC"
}
}
x-katara-request-id
string

Request id for support and for matching usage records.

Malformed request, or a feature the model does not support (feature_not_supported, with param naming the field for tool options).

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

Missing or unknown key (invalid_api_key).

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

The account is suspended (account_suspended).

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

Unknown model (model_not_found).

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

The balance behind the key cannot cover this request (insufficient_quota). Add USDC, or raise the budget cap, then retry.

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Retry-After
integer

Every provider tried answered with something the marketplace refused to deliver, such as a malformed tool call (provider_output_invalid). Nothing was charged. Retry after Retry-After.

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Retry-After
integer

No provider can take the request right now (no_capacity); a named model is never substituted. Retry after Retry-After, or ask katara/cortex@1.

Media typeapplication/json
object
error
required
object
message
required

For people. Wording may change.

string
type
required
string
Allowed values: invalid_request_error insufficient_quota server_error
code
required

Stable. Branch on this.

string
Allowed values: invalid_api_key model_not_found invalid_request feature_not_supported insufficient_quota account_suspended no_capacity internal_error
param
string | null
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Retry-After
integer