# Other endpoints

> Reference for Anthropic Messages, OpenAI Responses, Embeddings, Images, Key inspection, and API capabilities on HeyEly.

HeyEly speaks the exact wire protocols your existing SDKs already expect. Swap the base URL and API key, and leave the rest of your application intact. Looking to configure an editor or CLI instead? Head to [Coding tools](https://heyely.si/docs/coding-tools).

* OpenAI format (Most SDKs and tools): `https://heyely.si/v1`
* Anthropic format (Claude Code and the Anthropic SDK): `https://heyely.si`

Anthropic clients add `/v1/messages` themselves, so their base URL has no `/v1`. A doubled or missing `/v1` returns 404.

Authenticate using either `Authorization: Bearer sk-df-...` or `x-api-key: sk-df-...`. See [Authentication](https://heyely.si/docs/quickstart#keep-a-key-safe).

## Which endpoint

| Endpoint                                                            | Format                    | Use it for                                                                           |
| ------------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------ |
| [`POST /v1/chat/completions`](https://heyely.si/docs/api-reference/chat-completions) | OpenAI Chat Completions   | Default choice for most SDKs and tools: text, vision, tools, JSON schemas, streaming |
| [`POST /v1/completions`](https://heyely.si/docs/api-reference/chat-completions)      | OpenAI legacy Completions | Prompt-based text completions on models that expose legacy support                   |
| [`POST /v1/messages`](https://heyely.si/docs/api-reference#messages)                 | Anthropic Messages        | Claude Code and official Anthropic SDKs                                              |
| [`POST /v1/responses`](https://heyely.si/docs/api-reference#responses)               | OpenAI Responses          | Codex and clients using OpenAI's Responses API                                       |
| [`POST /v1/embeddings`](https://heyely.si/docs/api-reference#embeddings)             | OpenAI Embeddings         | Vector embeddings for semantic search and retrieval                                  |
| [`POST /v1/images`](https://heyely.si/docs/api-reference#images)                     | OpenRouter Images         | Dedicated image generation models                                                    |
| [`GET /v1/models`](https://heyely.si/docs/models)                                    | OpenAI list, extended     | Public catalog with IDs, rates, and capabilities (no key required)                   |
| [`GET /v1/key`](https://heyely.si/docs/api-reference#key)                            | HeyEly                    | Live inspection of key spend, cap, and account credit                                |

## Every response

* Every response across the six inference `POST` routes carries `x-request-id`, including errors. Once HeyEly opens a credit hold for a call, it appears in [Credit and usage](https://heyely.si/docs/concepts/credit-and-activation#usage) under that ID (even if the provider fails). Calls rejected before holding credit and `GET` calls are not logged there.
* Successful non-streamed responses carry `x-astra-cost` in micro-dollars. When the response body includes a generation ID, that header is provisional pending reconciliation. Images never carry a generation ID, so reported image costs are final immediately; if an image succeeds with no reported cost, it remains unresolved and the header reads `0`.
* Error payloads follow OpenAI's schema everywhere except Messages, which returns Anthropic's error envelope. See [Errors](https://heyely.si/docs/api-reference/errors).
* Any call accompanied by `PAYMENT-SIGNATURE` returns a base64 JSON `PAYMENT-RESPONSE` header once checked (whether succeeded or failed), containing either the Elysium settlement hash or an empty transaction when existing credit paid. See [Pay per request with x402](https://heyely.si/docs/concepts/credit-and-activation#pay-per-request-with-x402).

## What HeyEly changes

* Unrecognized request fields pass upstream so providers can ignore parameters a model does not implement. Routing overrides (`models`, `fallbacks`, `route`, `provider`) return `400 unsupported_parameter`, as do `plugins` entries other than `response-healing`, `file-parser` with `cloudflare-ai` or `native`, or `context-compression` with `enabled: false`.
* On Chat Completions and legacy Completions without an explicit output cap and without server tools, HeyEly may trim its default output cap so the hold fits your spendable balance. Explicit output caps you send are never lowered. Messages and Responses keep full output reservations and refuse requests whose holds exceed available credit.
* Chat Completions, legacy Completions, Embeddings, and Images overwrite `user` with an irreversible account tag. Every endpoint normalizes non-canonical model IDs (including stripping trailing `[1m]`) to the catalog ID, and Messages clamps `web_search` `max_uses`. Otherwise Messages and Responses forward payloads intact.
* HeyEly never persists prompts or model replies.

## Limits

Keys allow up to 300 requests per minute and 8 concurrent in-flight requests. Accounts that have never added paid credit share a 20-requests-per-minute account-wide cap across keys. Read [Rate limits](https://heyely.si/docs/api-reference/errors#rate-limits).

## Also in this reference

* [SDKs and clients](https://heyely.si/docs/api-reference/chat-completions): OpenAI, Anthropic, Vercel AI SDK, LiteLLM, and LangChain snippets
* Protocol compatibility: [OpenAI](https://heyely.si/docs/api-reference/chat-completions) and [Anthropic](https://heyely.si/docs/api-reference#anthropic-compatibility)
* Feature guides: [Streaming](https://heyely.si/docs/api-reference/chat-completions#streaming), [Tool calling](https://heyely.si/docs/api-reference/chat-completions#tools-and-json), [Structured outputs](https://heyely.si/docs/api-reference/chat-completions#tools-and-json), and [Prompt caching](https://heyely.si/docs/concepts/credit-and-activation#prompt-caching)
* [Docs for agents](https://heyely.si/docs/coding-tools#mcp-server): fetch any page as Markdown or connect over MCP

## Messages

**POST** `https://heyely.si/v1/messages`

Implements Anthropic's Messages wire format. Successful responses stream or return verbatim, while errors are normalized into Anthropic's error envelope (preserving valid Anthropic error types and client-facing wording). Payloads forward untouched aside from two gateway adjustments: normalizing non-catalog model IDs (stripping any trailing `[1m]`) and capping server-side `web_search` `max_uses` to the request's tool-step allowance. Configure Anthropic SDKs with `https://heyely.si` as the base URL (no `/v1` suffix).

### Send a request

**curl**

```bash
curl https://heyely.si/v1/messages \
  -H "x-api-key: $HEYELY_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "max_tokens": 1024,
    "messages": [{ "role": "user", "content": "Say hello in one sentence." }]
  }'
```

**Python**

```python
import os
import anthropic

client = anthropic.Anthropic(base_url="https://heyely.si", api_key=os.environ["HEYELY_API_KEY"])

message = client.messages.create(
    model="anthropic/claude-sonnet-5.5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(message.content[0].text)
```

**TypeScript**

```typescript
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://heyely.si",
  apiKey: process.env.HEYELY_API_KEY,
});

const message = await client.messages.create({
  model: "anthropic/claude-sonnet-5.5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(message.content);
```

### Headers

* `x-api-key` (string, required): Your HeyEly API key (`Authorization: Bearer sk-df-...` is also accepted).
* `anthropic-version` (string): Relayed upstream untouched; populated automatically by Anthropic SDKs.
* `anthropic-beta` (string): Relayed upstream untouched for any beta feature flags.

### Request body

* `model` (string, required): Catalog model ID, such as `anthropic/claude-sonnet-5.5`.
* `max_tokens` (integer): Output token cap. Required when a model publishes no maximum output (omitting it returns `400 output_cap_required`). Explicit values hold in full up to the model's maximum; omitting `max_tokens` reserves the model's entire published maximum output with no 32,768-token clamp, and HeyEly never injects an output cap of its own.
* `messages` (array, required): Alternating `user` and `assistant` turns with string or block-array content.
* `system` (string | array): System prompt; use block arrays to place `cache_control` markers.
* `stream` (boolean): Enable server-sent event streaming.
* `tools` (array): Tool definitions available to the model.
* `tool_choice` (object): Controls how the model selects tools.
* `temperature` (number): Sampling temperature.
* `thinking` (object): Extended thinking configuration on supporting models.

Query parameters such as `?beta=true` are safely ignored.

### Credit held

HeyEly reserves credit for prompt tokens, the full `max_tokens`, and allowed web-search steps, and never reduces `max_tokens` on Messages. A `web_search` tool's `max_uses` is clamped to the request's tool-step budget (30 by default, reducible via `max_tool_calls` unless `stop_server_tools_when` is present, which pins the budget at 30). Omitted or invalid `max_uses` inherits that allowance.

If your available balance or key cap cannot cover the hold, Messages answers `402` with `billing_error`: pass a smaller `max_tokens` or add credit. Calls covered by [free credit](https://heyely.si/docs/concepts/credit-and-activation#free-credit) run within their eligible hold. Read [Pricing](https://heyely.si/docs/concepts/credit-and-activation#pricing).

### Files and URLs

* Models process PDFs and other files natively only when they declare `file` input; otherwise HeyEly responds `400 unsupported_parameter` unless you enable the free parser via `"plugins": [{ "id": "file-parser", "pdf": { "engine": "cloudflare-ai" } }]`.
* Inline or URL-referenced files and URL-referenced images or videos reserve the larger of the text estimate and the model's context window (or 1,000,000 tokens if unknown).
* Non-streamed calls time out after 5 minutes if response headers do not arrive or body transfer stalls, and at 15 minutes overall, returning `504` with `error.type: timeout_error` (OpenAI endpoints return `error.code: upstream_timeout`). Nothing is billed yet and the hold stays reserved in case upstream completed the work. Streams have no total duration cap, though the same 5-minute header/body stall limits apply: stalling before headers costs zero, while after headers any reported cost is charged plus OpenRouter's 5% platform fee with no HeyEly markup. Stream long generations to avoid the 15-minute ceiling.

### Response

```json
{
  "id": "msg_01Ab3xQz9k",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-5.5",
  "content": [{ "type": "text", "text": "Hello, nice to meet you." }],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 14, "output_tokens": 9 }
}
```

When prompt caching triggers, `usage` also includes `cache_creation_input_tokens` and `cache_read_input_tokens`.

### Errors

Messages errors use Anthropic's envelope (`type: "error"`) carrying HeyEly's `request_id`, mirrored in both `x-request-id` and `request-id` headers. See [Errors](https://heyely.si/docs/api-reference/errors).

## Responses

**POST** `https://heyely.si/v1/responses`

Implements OpenAI's Responses wire format. Once validated, payloads forward after normalizing non-catalog model IDs (and stripping trailing `[1m]`). Routing overrides (`models`, `fallbacks`, `route`, `provider`), paid `plugins`, tool types outside `function`, `custom`, and supported web search, `x_search`, and audio input all return `400 unsupported_parameter`. Sending a file to a model lacking native file support also returns `400` unless `"plugins": [{ "id": "file-parser", "pdf": { "engine": "cloudflare-ai" } }]` is included. Responses is strictly stateless: include the full conversation history in `input` on every turn. Authenticate with `Authorization: Bearer sk-df-...`.

### Send a request

**curl**

```bash
curl https://heyely.si/v1/responses \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "input": "Say hello in one sentence."
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

response = client.responses.create(
    model="anthropic/claude-sonnet-5.5",
    input="Say hello in one sentence.",
)
print(response.output_text)
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://heyely.si/v1",
  apiKey: process.env.HEYELY_API_KEY,
});

const response = await client.responses.create({
  model: "anthropic/claude-sonnet-5.5",
  input: "Say hello in one sentence.",
});
console.log(response.output_text);
```

### Request body

* `model` (string, required): Catalog model ID.
* `input` (string | array, required): Single text prompt or full array of conversation items.
* `instructions` (string): System-level instructions for the turn.
* `stream` (boolean): Enable server-sent event streaming (used by Codex).
* `tools` (array): Flat tool declarations available to the model.
* `max_output_tokens` (integer): Output token limit, which also bounds the credit hold.
* `reasoning` (object): Reasoning configuration on models that expose it.
* `store` (boolean): Omit or set `false`; persisted server-side responses are unsupported and return `400`.
* `previous_response_id` (string): Unsupported; pass prior turns explicitly inside `input`.

### Streaming

Responses streams terminate with `response.completed`, `response.incomplete` (detailing why in `incomplete_details`), `response.failed`, or an `error` event. Terminal events contain the final response payload and provider-reported usage. Codex waits for `response.completed`. Read [Streaming events](https://heyely.si/docs/api-reference/chat-completions#streaming) for the full sequence.

### Models

Model behavior on Responses varies across upstream providers. If a specific model struggles with Codex-style Responses payloads, switch models. See [Codex](https://heyely.si/docs/coding-tools/codex-cli).

## Embeddings

**POST** `https://heyely.si/v1/embeddings`

Implements OpenAI's Embeddings format. Pass an embedding model ID (listed in `GET /v1/models` with `embeddings` under `architecture.output_modalities`) and authenticate with `Authorization: Bearer sk-df-...` or `x-api-key`.

### Send a request

**curl**

```bash
curl https://heyely.si/v1/embeddings \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": "A ledger is a list of entries."
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

result = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input="A ledger is a list of entries.",
)
print(len(result.data[0].embedding))
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://heyely.si/v1",
  apiKey: process.env.HEYELY_API_KEY,
});

const result = await client.embeddings.create({
  model: "openai/text-embedding-3-small",
  input: "A ledger is a list of entries.",
});
console.log(result.data[0].embedding.length);
```

### Request body

* `model` (string, required): Embedding model ID.
* `input` (string | array, required): Single string or batch array of strings to embed.
* `encoding_format` (string): `float` (default) returns numeric arrays; `base64` returns encoded strings.
* `dimensions` (integer): Optional truncated vector length on supporting models.

HeyEly replaces any `user` field with an internal account tag.

### Response

```json
{
  "object": "list",
  "data": [{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456] }],
  "model": "openai/text-embedding-3-small",
  "usage": { "prompt_tokens": 8, "total_tokens": 8 }
}
```

The vector above is abbreviated. Because embeddings run strictly on open models, responses carrying `usage.cost` bill that figure plus OpenRouter's 5% platform fee with zero HeyEly markup (final immediately if no generation ID is present, or provisional when one is). Without `usage.cost`, token counts paired with a generation ID produce a provisional estimate; lacking both leaves nothing billed yet while keeping the hold reserved. `x-astra-cost` reports the amount in micro-dollars.

## Images

**POST** `https://heyely.si/v1/images`

Generates images from a model ID and prompt, returning `data` entries containing either `b64_json` or a `url`. This route follows OpenRouter's Images schema rather than OpenAI's `/v1/images/generations`. Authenticate via `Authorization: Bearer sk-df-...` or `x-api-key`.

Find image generation models in `GET /v1/models` by filtering for `image` in `architecture.output_modalities`.

### Send a request

**curl**

```bash
curl https://heyely.si/v1/images \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "recraft/recraft-v4.1-flash",
    "prompt": "A lighthouse on a cliff at dawn, flat illustration",
    "n": 1
  }' | jq -r '.data[0].b64_json' | base64 --decode > lighthouse.png
```

**Python**

```python
import base64
import os
import requests

response = requests.post(
    "https://heyely.si/v1/images",
    headers={"Authorization": f"Bearer {os.environ['HEYELY_API_KEY']}"},
    json={
        "model": "recraft/recraft-v4.1-flash",
        "prompt": "A lighthouse on a cliff at dawn, flat illustration",
        "n": 1,
    },
    timeout=180,
)
response.raise_for_status()
for index, image in enumerate(response.json()["data"]):
    with open(f"image-{index}.png", "wb") as file:
        file.write(base64.b64decode(image["b64_json"]))
```

**TypeScript**

```typescript
import { writeFile } from "node:fs/promises";

const response = await fetch("https://heyely.si/v1/images", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.HEYELY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "recraft/recraft-v4.1-flash",
    prompt: "A lighthouse on a cliff at dawn, flat illustration",
    n: 1,
  }),
  signal: AbortSignal.timeout(180_000),
});
if (!response.ok) throw new Error(await response.text());

const { data } = await response.json();
for (const [index, image] of data.entries()) {
  await writeFile(`image-${index}.png`, Buffer.from(image.b64_json, "base64"));
}
```

### Request body

* `model` (string, required): Image model ID.
* `prompt` (string, required): Text description of the image to generate.
* `n` (integer): Number of images to generate (integer from 1 to 10, defaulting to 1; out-of-range values return `400 invalid_parameter`).
* `aspect_ratio` (string): Ratio string such as `16:9` on supporting models.
* `resolution` (string): Named size such as `1K` or `2K` on supporting models.
* `size` (string): Pixel dimensions such as `1024x1024` where accepted.
* `quality` (string): Quality tier where offered by the model.
* `output_format` (string): `png`, `jpeg`, or `webp` on models supporting format selection.
* `input_references` (array): Reference images for image-guided generation where supported.
* `stream` (boolean): Enable SSE partial-image streaming (supported by OpenAI image models only).

Extra fields pass upstream (and unsupported fields are ignored by the provider). `models`, `fallbacks`, `route`, and `provider` return `400 unsupported_parameter`, along with any `plugins` entry other than `response-healing`, `file-parser` on `cloudflare-ai` or `native`, or `context-compression` with `enabled: false`. HeyEly replaces `user` with an account tag.

### Response

```json
{
  "created": 1760000000,
  "data": [{ "b64_json": "iVBORw0KGgo...", "media_type": "image/png" }],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "cost": 0.007
  }
}
```

Each item in `data` includes `b64_json` (truncated above) or `url`, plus `media_type` indicating the output format. Images execute on open models only, so `usage.cost` is the raw provider USD figure before OpenRouter's 5% [platform fee](https://heyely.si/docs/concepts/credit-and-activation#pricing). Your total billed amount appears in Credit and usage and in `x-astra-cost` (micro-dollars) on completed non-streamed calls.

### Streaming

When `stream: true` is sent to a streaming image model, HeyEly relays `image_generation.partial_image` progress frames, a final `image_generation.completed` event containing the finished image and usage, and `[DONE]` (or an `error` event if generation fails).

### Billing

* Per requested image, HeyEly holds the maximum of $0.20, the catalog per-input-image price (`pricing.image`), and 8,192 tokens at the model's highest image-output token rate (not exposed in `GET /v1/models`), plus any per-request charge. Insufficient room returns `402`; request fewer images or top up credit.
* Completed images bill `usage.cost` plus OpenRouter's 5% platform fee with no HeyEly markup. Because image responses carry no generation ID, that charge finalizes immediately; if a successful response omits `usage.cost`, it stays unresolved with its hold reserved.
* Failed image calls bill any provider-reported cost plus OpenRouter's 5% platform fee with zero markup (typically zero). A non-streamed timeout charges nothing yet and keeps its hold reserved, because the upstream provider may still have rendered the image.
* Free credit never pays for images; accounts with only free credit receive `402 free_credit_not_eligible`.

### Limits

| Limit              | Value                                                 | When exceeded                                                                                                |
| ------------------ | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Request body       | 64 MB                                                 | `413 request_too_large`                                                                                      |
| Time to generate   | 120 seconds from upstream dispatch, including streams | Non-streamed calls return `504 upstream_timeout` with hold reserved; streamed timeouts follow the rule below |
| Images per request | 10                                                    | `400 invalid_parameter`                                                                                      |

Because rendering can take longer than 60 seconds, configure client timeouts of at least 180 seconds.

A streamed timeout before response headers returns `504 upstream_timeout` and costs zero. After headers, a timeout interrupts the HTTP `200` stream. A reported cost is charged plus OpenRouter's 5% platform fee. HeyEly adds no markup. Token counts with a generation id are a provisional estimate. Anything else does not charge the hold.

### Also from chat

Multimodal chat models (such as Gemini and GPT image-capable models) can emit images directly inside chat completions by passing `modalities: ["image", "text"]` to [Chat Completions](https://heyely.si/docs/api-reference/chat-completions). Dedicated image models like Recraft and FLUX require `POST /v1/images`.

## Key

**GET** `https://heyely.si/v1/key`

Inspects the active API key's spend, cap, and account credit balances, handy for status bars, CI guardrails, and monitoring scripts. Authenticate with `Authorization: Bearer sk-df-...` or `x-api-key`.

### Send a request

**curl**

```bash
curl https://heyely.si/v1/key \
  -H "Authorization: Bearer $HEYELY_API_KEY"
```

**Python**

```python
import os
import requests

response = requests.get(
    "https://heyely.si/v1/key",
    headers={"Authorization": f"Bearer {os.environ['HEYELY_API_KEY']}"},
)
print(response.json()["data"]["credit_available"])
```

**TypeScript**

```typescript
const response = await fetch("https://heyely.si/v1/key", {
  headers: { Authorization: `Bearer ${process.env.HEYELY_API_KEY}` },
});
const { data } = await response.json();
console.log(data.credit_available);
```

### Response

```json
{
  "data": {
    "name": "claude-code",
    "label": "sk-df-Ab3x...Qz9k",
    "limit": 50,
    "usage": 12.4,
    "limit_remaining": 37.6,
    "credit_available": 112.8,
    "free_credit_available": 1.25,
    "free_credit_expires_at": "2026-11-07T00:00:00.000Z",
    "expires_at": null
  }
}
```

### Fields

* `name` (string): User-assigned key name.
* `label` (string): Masked key identifier.
* `limit` (number | null): Configured spend limit in US dollars, or `null` if uncapped.
* `usage` (number): Cumulative US dollars spent by this key.
* `limit_remaining` (number | null): Remaining spend allowance (`limit` minus `usage` and active holds on this key, floored at `0`), or `null` if uncapped.
* `credit_available` (number): Spendable paid account credit in US dollars (balance minus active holds, floored at `0`), excluding free credit.
* `free_credit_available` (number): Spendable unexpired free credit in US dollars minus active holds (`0` if none). See [Free credit](https://heyely.si/docs/concepts/credit-and-activation#free-credit).
* `free_credit_expires_at` (string | null): ISO 8601 timestamp of the earliest upcoming free credit expiration, or `null` if none applies.
* `expires_at` (string | null): ISO 8601 key expiration timestamp, or `null` if non-expiring.

### Errors

Invalid or disabled keys trigger the standard OpenAI-envelope authentication errors documented in [Authentication](https://heyely.si/docs/quickstart#keep-a-key-safe).

## Anthropic compatibility

`POST /v1/messages` implements Anthropic's Messages protocol. Because Claude Code and Anthropic's official SDKs append `/v1/messages` automatically, configure their base URL as `https://heyely.si` without `/v1`.

```python
import anthropic

client = anthropic.Anthropic(
    base_url="https://heyely.si",
    api_key="sk-df-...",
)

message = client.messages.create(
    model="anthropic/claude-sonnet-5.5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(message.content[0].text)
```

### What passes through

* `anthropic-version` and `anthropic-beta` headers pass straight through, and payloads keep Anthropic's exact structure including thinking and tool-use blocks.
* SSE streams (including `ping` keepalives) relay chunk-by-chunk with zero buffering.
* `system` and `cache_control` blocks stay untouched so Anthropic prompt caching works seamlessly.
* Trailing query flags such as `?beta=true` are ignored cleanly.
* Client-side provider statuses (`400`, `403`, `404`, `408`, `409`, `413`, `422`, and `429`) keep their HTTP code and are wrapped in Anthropic's error envelope, preserving valid Anthropic error types and client-facing messages while stripping provider internals. Non-standard bodies use HeyEly's mapped type and standard wording. Upstream `401` and `402` map to `503 overloaded_error`; all other upstream errors map to `502 api_error`. `retry-after` relays as integer seconds (HTTP-date values are dropped).
* `anthropic-ratelimit-*` and `x-should-retry` headers forward whenever returned by the provider.

Choose a `max_tokens` value your available balance can hold, since HeyEly never lowers it on Messages. Server-run `web_search` tools cap `max_uses` at the request's tool-step allowance (up to 30, defaulting to that allowance when omitted). See [Messages](https://heyely.si/docs/api-reference#credit-held).

### Credentials

Pass your key via `x-api-key: sk-df-...` (Anthropic SDK default) or `Authorization: Bearer sk-df-...` (sent by Claude Code when `ANTHROPIC_AUTH_TOKEN` is configured).

### Model ids

Pass catalog IDs like `anthropic/claude-sonnet-5.5`. HeyEly accepts a trailing `[1m]` suffix, strips it before catalog lookup, and forwards the base catalog ID without `[1m]`. Non-Anthropic models are callable through Messages too, though extended thinking and tool blocks follow each model's native support.

### Errors

Anthropic-format errors set `type: "error"`, populate `error.type` and `error.message`, and stamp HeyEly's `request_id` (matching both `x-request-id` and `request-id` headers). Gateway `409` responses use `conflict_error` and gateway `504` responses use `timeout_error`. Read [Errors](https://heyely.si/docs/api-reference/errors).

### Not available

`POST /v1/messages/count_tokens` is not exposed; Claude Code automatically switches to local token estimation when token counting is absent.

## What your key can do

A single HeyEly API key unlocks every modality in the catalog. Pick a workflow below to copy a runnable request and jump straight to the matching reference section.

* [Text](#text): Chat Completions
* [Vision](#vision): Chat Completions
* [Image generation](#image-generation): Images
* [Embeddings](#embeddings): Embeddings
* [Tool calling](#tool-calling): Chat Completions
* [Structured outputs](#structured-outputs): Chat Completions
* [Reasoning](#reasoning): Chat Completions

Every snippet reads `HEYELY_API_KEY` from your environment. Need a key first? Follow [Quickstart](https://heyely.si/docs/quickstart).

### Text

Send conversation turns and receive a reply, or add `"stream": true` for real-time token streaming.

**curl**

```bash
curl https://heyely.si/v1/chat/completions \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v3.2",
    "messages": [{ "role": "user", "content": "Explain a ledger in one sentence." }],
    "max_tokens": 200
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

response = client.chat.completions.create(
    model="deepseek/deepseek-v3.2",
    messages=[{"role": "user", "content": "Explain a ledger in one sentence."}],
    max_tokens=200,
)
print(response.choices[0].message.content)
```

[Browse text models](https://heyely.si/docs/models), or dive into [Chat Completions](https://heyely.si/docs/api-reference/chat-completions) and [Streaming](https://heyely.si/docs/api-reference/chat-completions#streaming).

### Vision

Include an `image_url` content part alongside your text prompt using either a public URL or a base64 `data:` URI.

**curl**

```bash
curl https://heyely.si/v1/chat/completions \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [{
      "role": "user",
      "content": [
        { "type": "text", "text": "What is in this image?" },
        { "type": "image_url", "image_url": {
          "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/960px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
        } }
      ]
    }],
    "max_tokens": 300
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

url = (
    "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/"
    "Gfp-wisconsin-madison-the-nature-boardwalk.jpg/"
    "960px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
)
response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What is in this image?"},
            {"type": "image_url", "image_url": {"url": url}},
        ],
    }],
    max_tokens=300,
)
print(response.choices[0].message.content)
```

PNG, JPEG, WebP, and GIF inputs are accepted and metered as input tokens. Find vision-capable models by checking `image` in `architecture.input_modalities` via `GET /v1/models`.

### Image generation

Call `POST /v1/images` with an image model and prompt to generate base64-encoded images (allow over a minute for rendering).

**curl**

```bash
curl https://heyely.si/v1/images \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "recraft/recraft-v4.1-flash",
    "prompt": "A lighthouse on a cliff at dawn, flat illustration"
  }' | jq -r '.data[0].b64_json' | base64 --decode > lighthouse.png
```

**Python**

```python
import base64
import os
import requests

response = requests.post(
    "https://heyely.si/v1/images",
    headers={"Authorization": f"Bearer {os.environ['HEYELY_API_KEY']}"},
    json={
        "model": "recraft/recraft-v4.1-flash",
        "prompt": "A lighthouse on a cliff at dawn, flat illustration",
    },
    timeout=180,
)
response.raise_for_status()
image = response.json()["data"][0]["b64_json"]
with open("lighthouse.png", "wb") as file:
    file.write(base64.b64decode(image))
```

Paid credit is required because free credit never covers image generation. Look for `image` in `architecture.output_modalities` on `GET /v1/models`, and read [Images](https://heyely.si/docs/api-reference#images).

### Embeddings

Convert text snippets into dense numerical vectors for indexing, clustering, and semantic retrieval.

**curl**

```bash
curl https://heyely.si/v1/embeddings \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": "A ledger is a list of entries."
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

result = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input="A ledger is a list of entries.",
)
print(len(result.data[0].embedding))
```

Embedding models list `embeddings` under `architecture.output_modalities` in `GET /v1/models`. Read [Embeddings](https://heyely.si/docs/api-reference#embeddings).

### Tool calling

Declare callable schemas inside `tools`. Whenever the model decides to invoke a function, it responds with structured `tool_calls` naming the function and its JSON arguments.

**curl**

```bash
curl https://heyely.si/v1/chat/completions \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [{ "role": "user", "content": "What is the weather in Lisbon?" }],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }]
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[{"role": "user", "content": "What is the weather in Lisbon?"}],
    tools=tools,
)
print(response.choices[0].message.tool_calls)
```

Models supporting function calling list `tools` inside `supported_parameters` on `GET /v1/models`. See [Tool calling](https://heyely.si/docs/api-reference/chat-completions#tools-and-json) for returning results and completing the loop.

### Structured outputs

Pass a JSON Schema inside `response_format` so replies conform cleanly to your expected object shape.

**curl**

```bash
curl https://heyely.si/v1/chat/completions \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [{ "role": "user", "content": "Extract: Ada paid $12.40 on Oct 8." }],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "payment",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "name": { "type": "string" },
            "amount_usd": { "type": "number" }
          },
          "required": ["name", "amount_usd"],
          "additionalProperties": false
        }
      }
    }
  }'
```

**Python**

```python
import json
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[{"role": "user", "content": "Extract: Ada paid $12.40 on Oct 8."}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "payment",
            "strict": True,
            "schema": {
                "type": "object",
                "properties": {
                    "name": {"type": "string"},
                    "amount_usd": {"type": "number"},
                },
                "required": ["name", "amount_usd"],
                "additionalProperties": False,
            },
        },
    },
)
print(json.loads(response.choices[0].message.content))
```

Verify that your chosen model exposes `response_format` or `structured_outputs` in its supported parameters, and read [Structured outputs](https://heyely.si/docs/api-reference/chat-completions#tools-and-json).

### Reasoning

Reasoning-capable models work through intermediate steps before answering. Pass `reasoning` to tune thinking depth; internal thoughts arrive in `message.reasoning` and bill at the output token rate.

**curl**

```bash
curl https://heyely.si/v1/chat/completions \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [{ "role": "user", "content": "Is 9.11 larger than 9.9?" }],
    "reasoning": { "effort": "high" },
    "max_tokens": 4000
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://heyely.si/v1", api_key=os.environ["HEYELY_API_KEY"])

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5.5",
    messages=[{"role": "user", "content": "Is 9.11 larger than 9.9?"}],
    max_tokens=4000,
    extra_body={"reasoning": {"effort": "high"}},
)
print(response.choices[0].message.content)
```

Set `effort` to `low`, `medium`, or `high`, or pass an explicit token budget with `reasoning.max_tokens`. On `POST /v1/messages`, pass Anthropic's `thinking` object instead. Reasoning models advertise `reasoning` in `supported_parameters` on `GET /v1/models`.
