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/v1Endpoints
| Endpoint | Format | Description |
|---|---|---|
POST /v1/chat/completions | OpenAI Chat Completions | Generates a response to a list of messages. Supports streaming, tools, reasoning, and image input. |
POST /v1/completions | OpenAI Completions | Continues a raw text prompt without a chat template. For details, see Raw prompts and log probabilities. |
POST /v1/messages | Anthropic Messages | Generates a response in the Anthropic Messages format. |
POST /v1/messages/count_tokens | Anthropic Messages | Returns an estimate of the number of input tokens for a request. |
POST /v1/responses | OpenAI Responses | Generates a response in the OpenAI Responses format. |
GET /v1/models | OpenAI Models | Lists the available models with their capabilities and prices. |
POST /v2/video_generation | MiniMax video generation | Submits 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.
| Situation | Behavior |
|---|---|
max_tokens is omitted | The 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 length | Engy reduces it to the maximum output length. |
The prompt plus max_tokens exceeds the context window | The 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.
| Field | Type | Description |
|---|---|---|
provider.zdr | Boolean | If true, only workers with zero data retention serve the request. For details, see Data retention. |
provider.region_only | Array | Only workers in these regions serve the request. For details, see Region routing. |
provider.region_exclude | Array | Workers in these regions do not serve the request. For details, see Region routing. |
provider.require_proof | Boolean | If 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 header | Where it appears | Description |
|---|---|---|
X-Engy-Request-Id header | All inference responses, including errors | The unique identifier of the request. Include it when you contact support. |
X-Engy-Charged-Micro header | Non-streaming responses from /v1/chat/completions, /v1/completions, and /v1/messages | The amount charged, in micro-USD. One USD equals 1,000,000 micro-USD. |
x_engy.request_id | Non-streaming bodies from /v1/chat/completions and /v1/completions, and the final streaming chunk | The same request identifier. |
x_engy.charged_micro | Non-streaming bodies from /v1/chat/completions and /v1/completions, and the final streaming chunk | The same charged amount. |
usage.cost | The final streaming chunk of /v1/chat/completions | The 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 setstemperatureto1.0andtop_pto0.95. If you sendn,presence_penalty, orfrequency_penalty, Engy sets them to1,0, and0.qwen3.6-35b-a3bandqwen3.8-27b: Asystemmessage that is not the first message is sent to the model as ausermessage.- All models: If you set
tool_choicetonone, 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:
| Endpoint | Not supported |
|---|---|
/v1/messages | cache_control, metadata, document blocks, images in assistant turns, and thinking.budget_tokens. These are ignored. |
/v1/responses | Stored 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
- Streaming: Receive responses incrementally.
- Errors and limits: Handle errors and capacity limits.
- Inference API reference: Look up the parameters and response fields of each endpoint.