Skip to content

API overview

Learn which endpoints the Engy inference API provides, how to authenticate, and how Engy extends the standard request and response formats.

This page describes the Engy inference API as a whole: its endpoints, authentication, model IDs, and the fields that Engy adds to standard requests and responses. It is intended for developers who integrate Engy into an application or connect an existing OpenAI or Anthropic client.

Base URL

All inference endpoints use the following base URL:

https://api.engy.ai/v1

Endpoints

EndpointFormatDescription
POST /v1/chat/completionsOpenAI Chat CompletionsGenerates a response to a list of messages. Supports streaming, tools, reasoning, and image input.
POST /v1/completionsOpenAI CompletionsContinues a raw text prompt without a chat template. For details, see Raw prompts and log probabilities.
POST /v1/messagesAnthropic MessagesGenerates a response in the Anthropic Messages format.
POST /v1/messages/count_tokensAnthropic MessagesReturns an estimate of the number of input tokens for a request.
POST /v1/responsesOpenAI ResponsesGenerates a response in the OpenAI Responses format.
GET /v1/modelsOpenAI ModelsLists the available models with their capabilities and prices.
POST /v2/video_generationMiniMax video generationSubmits an asynchronous video generation task. For details, see Video generation.

Authentication

Authenticate each request with an API key. API keys start with sk-engy-. To create one, see API keys.

Send the key in the Authorization header:

curl https://api.engy.ai/v1/chat/completions \
  -H "Authorization: Bearer $ENGY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.2", "messages": [{"role": "user", "content": "Hello"}]}'

The /v1/messages endpoint also accepts the key in the x-api-key header, as Anthropic clients send it:

curl https://api.engy.ai/v1/messages \
  -H "x-api-key: $ENGY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "glm-5.2", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

The GET /v1/models endpoint does not require a key. If you send a valid key, the prices in the response reflect any pricing that applies to your account.

A deleted API key can continue to authorize requests for a few seconds before the deletion takes effect everywhere.

Use an existing client

Engy is compatible with the official OpenAI and Anthropic SDKs. Change the base URL and the API key, and keep the rest of your code.

import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.engy.ai/v1",
    api_key=os.environ["ENGY_API_KEY"],
)

response = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.choices[0].message.content)

The Anthropic SDK appends /v1 to the base URL itself. Set the base URL to https://api.engy.ai, without /v1.

To send Engy-specific fields, such as the provider object, from the OpenAI Python SDK, pass them in extra_body:

response = client.chat.completions.create(
    model="glm-5.2",
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={"provider": {"zdr": True}},
)

Model IDs

Specify the model in the model parameter. For the list of model IDs, see Models and pricing.

Some clients require model names in vendor/model form. Engy accepts one leading vendor segment and ignores it, so engy/glm-5.2 and glm-5.2 select the same model. The response returns the model name as you sent it.

Output length

The max_tokens parameter sets the maximum number of output tokens. On /v1/chat/completions, max_completion_tokens takes precedence over max_tokens if you send both.

SituationBehavior
max_tokens is omittedThe model can generate up to its maximum output length, within the space that remains in the context window.
max_tokens exceeds the model's maximum output lengthEngy reduces it to the maximum output length.
The prompt plus max_tokens exceeds the context windowThe request fails with HTTP status 400. On /v1/messages, Engy reduces max_tokens to fit instead.

Before a request starts, Engy reserves credit for the maximum possible cost, which depends on max_tokens. If you omit max_tokens, the reservation covers the model's full output length. Set a smaller max_tokens to reduce the balance that a request requires. For details, see Credits and payments.

Engy request fields

Engy accepts the following fields in addition to the standard request format. They work on /v1/chat/completions, /v1/completions, /v1/messages, and /v1/responses.

FieldTypeDescription
provider.zdrBooleanIf true, only workers with zero data retention serve the request. For details, see Data retention.
provider.region_onlyArrayOnly workers in these regions serve the request. For details, see Region routing.
provider.region_excludeArrayWorkers in these regions do not serve the request. For details, see Region routing.
provider.require_proofBooleanIf true, the response includes a proof that you can verify. For details, see Verify responses.

Engy removes the provider object before the request reaches the model.

Engy response fields

Engy adds the following information to responses:

Field or headerWhere it appearsDescription
X-Engy-Request-Id headerAll inference responses, including errorsThe unique identifier of the request. Include it when you contact support.
X-Engy-Charged-Micro headerNon-streaming responses from /v1/chat/completions, /v1/completions, and /v1/messagesThe amount charged, in micro-USD. One USD equals 1,000,000 micro-USD.
x_engy.request_idNon-streaming bodies from /v1/chat/completions and /v1/completions, and the final streaming chunkThe same request identifier.
x_engy.charged_microNon-streaming bodies from /v1/chat/completions and /v1/completions, and the final streaming chunkThe same charged amount.
usage.costThe final streaming chunk of /v1/chat/completionsThe amount charged, in USD.

Non-streaming chat and completion responses contain only the fields id, object, created, model, choices, usage, and x_engy. Other OpenAI fields, such as system_fingerprint, are not returned.

Model-specific behavior

Some models enforce fixed request contracts. Engy applies them so that results are consistent:

  • kimi-k3: Sampling parameters are fixed. Engy always sets temperature to 1.0 and top_p to 0.95. If you send n, presence_penalty, or frequency_penalty, Engy sets them to 1, 0, and 0.
  • qwen3.6-35b-a3b and qwen3.8-27b: A system message that is not the first message is sent to the model as a user message.
  • All models: If you set tool_choice to none, Engy removes any tool calls from the response. For details, see Tool calling.

Endpoint differences

The /v1/messages and /v1/responses endpoints translate requests into the chat format. The following parts of these formats are not supported:

EndpointNot supported
/v1/messagescache_control, metadata, document blocks, images in assistant turns, and thinking.budget_tokens. These are ignored.
/v1/responsesStored responses (store and previous_response_id), image input, structured outputs (text.format), the reasoning object, and prompt_cache_key. These are ignored.

The /v1/responses endpoint is stateless. Send the full conversation in input with each request.

Next steps