Skip to content

Generate an image

POST
/images/generations
curl --request POST \
--url https://api.katara.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "katara/cortex", "prompt": "A watercolor koi pond at dawn", "aspect_ratio": "16:9" }'

The OpenAI image generation request. One image per request, returned as base64. Any model name is served by Katara Cortex, which makes the picture with the main image model (priced by image_size: 0.05112 at 1K, 0.07128 at 2K, 0.1464 at 4K) and, when it cannot, a lower-cost image model (0.018 USDC or credits). A USDC key is charged that price, a credits key the credit price, and without a key the x402 quote is exactly that price. Nothing is charged unless the image comes back. Images never reach Katara Community. Images describes the fields.

PAYMENT-SIGNATURE
string

Without a key, base64 of the x402 payment payload that signs the quote from a previous 402.

X-PAYMENT
string

The same payload under the header name of the first x402 version, paid with exact.

Media typeapplication/json
object
model
required

Any name; Katara Cortex serves every image request.

string
prompt
required

What to draw.

string
<= 4000 characters
size

WIDTHxHEIGHT, each side 1024 to 2048 and a multiple of 32, at most 4,194,304 pixels; or auto for the default. For a model priced by size, the closest listed shape within 3% at the smallest size with at least that many pixels. Not sent with image_size or aspect_ratio.

string
default: 1280x1280
image_size

For a model priced by size. Defaults to the model’s default_image_size.

string
Allowed values: 1K 2K 4K
aspect_ratio

For a model priced by size.

string
Allowed values: 1:1 2:3 3:2 3:4 4:3 4:5 5:4 9:16 16:9 21:9
quality

hd (about 20 seconds) or standard (5 to 10 seconds); high and auto mean hd, medium and low mean standard.

string
default: hd
Allowed values: hd standard high medium low auto
n

One image per request.

integer
Allowed values: 1
response_format
string
Allowed values: b64_json
user

Accepted and not passed on.

string
Example
{
"model": "katara/cortex",
"prompt": "A watercolor koi pond at dawn",
"aspect_ratio": "16:9"
}

The image.

Media typeapplication/json
object
created
required
integer
data
required
Array<object>
<= 1 items
object
b64_json

The image, base64-encoded.

string
output_format
string
Allowed values: png jpeg webp
usage
required
object
images

The images charged for.

integer
katara
object
Any of:

What this reply cost.

object
cost_usdc
required

The settled price, in USDC, as a decimal string. For a request paid with x402 it is the charge, the model’s minimum included (0.025 USDC, 0.05 for katara/cortex-genius, 0.01 for katara/cortex-smart).

string
cost_usd

The Credits charge as a decimal string. This legacy field name is retained for compatibility; display Credits without a dollar sign.

string
billing_method
string
Allowed values: credits usdc
payment

On a request paid with x402, the payment that settles the reply.

object
scheme
string
Allowed values: upto exact
network
string
asset

The token paid.

string
amount

The charge in the token’s base units, the same as amount in PAYMENT-RESPONSE.

string
provider

The provider’s address, or managed when a vendor answered.

string
cached_tokens

Prompt tokens the vendor read from its cache, billed at the cached input rate.

integer
cache_saving_usdc

What the cached tokens saved against the input rate, in USDC.

string
cache_saving_usd

The same saving in Credits, on a reply paid with account credits.

string
compaction

When katara.compaction summarised the conversation.

object
message

The system message to send in place of the summarised messages.

object
replaces_from

First index in this request’s messages that the summary replaces.

integer
replaces_to

First index kept after it.

integer
model
string
tokens_before
integer
summary

The summary request’s usage and its cost (cost_usdc or cost_usd).

object
skipped

Why no summary was made; the request went whole.

string
context_edits
object
cleared_tool_results
integer
cleared_tokens
integer
through_turn
integer
cache_written_tokens

Tokens this request wrote to a new explicit cache (katara.cache).

integer
cache_ttl_seconds

How long that cache is kept.

integer
cache_storage_usdc

What keeping it costs, in USDC; included in cost_usdc.

string
simulated

On Test, a reply with fixed text that no model wrote, served when no Test provider was free.

boolean
stop_sequence

The stop sequence at which Katara ended the reply.

string
web_search

The searches this request was charged for.

object
requests

The successful searches; only those are charged, and none when the request ended without an answer.

integer
cost_usdc
string
cost_usd
string
model_calls

On a web search request, how many model calls it made.

integer
web_searches

Every search the model made, in order. Not on stream chunks, which carry each search as it runs.

Array<object>
object
id
required
string
query
required
string
results
required
Array<object>
object
url
string
title
string
page_age
string
content
string
error
string
Allowed values: invalid_input query_too_long too_many_requests unavailable max_uses_exceeded insufficient_quota
edit_id

On an image reply from a model that edits, the id to send as previous_edit_id.

string
edit_id

From a model that edits: send as previous_edit_id to keep editing this picture.

string
Example
{
"output_format": "png",
"katara": {
"cost_usdc": "0.000018",
"cost_usd": "0.000018",
"billing_method": "credits",
"payment": {
"scheme": "upto",
"network": "eip155:43114",
"amount": "25000"
},
"web_searches": [
{
"error": "invalid_input"
}
]
}
}
PAYMENT-RESPONSE
string

On a call paid with x402, as for chat completions; amount is the charge.

A field the route does not take (unsupported_parameter, with param), a malformed request (invalid_request), a prompt the model refused (image_refused), an expired previous_edit_id (edit_expired), or a credits key and a model its credits cannot pay for (model_requires_usdc).

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 rate_limit_error server_error
code
required

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

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 rate_limit_error server_error
code
required

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

Without a key, a quote (with PAYMENT-REQUIRED) or a payment that does not verify (payment_invalid); with a credits key, insufficient_credits; with a USDC key whose balance cannot cover the call, insufficient_quota.

Media typeapplication/json
One of:
object
error
required
object
message
required

For people. Wording may change.

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

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
PAYMENT-REQUIRED
string

Base64 of the PaymentRequired object in the body. Present only on a quote.

Too many unpaid quotes from one address (quote_rate_limited).

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 rate_limit_error server_error
code
required

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Retry-After
integer

The image provider failed (provider_failed, with Retry-After) or could not take the request Katara built (provider_rejected_request). Nothing was charged.

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 rate_limit_error server_error
code
required

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}

The model cannot be served right now (no_capacity). 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 rate_limit_error server_error
code
required

Stable. Branch on this. Errors says what each code means and what to do; new codes may be added.

string
Allowed values: invalid_api_key model_not_found model_requires_x402 model_requires_usdc invalid_request invalid_value invalid_web_search context_length_exceeded feature_not_supported media_too_large insufficient_quota insufficient_credits funding_pending community_off account_suspended billing_suspended wrong_environment no_capacity upstream_timeout test_network_unavailable payment_invalid permit2_allowance_required quote_rate_limited unsupported_parameter provider_failed provider_output_invalid provider_rejected_request provider_rate_limited provider_overloaded request_too_large not_found method_not_allowed storage_unavailable internal_error
param
string | null
request_id

The response’s x-katara-request-id.

string
Example
{
"error": {
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
Retry-After
integer