Text generation

Introduction

Text generation is OpenAI-compatible. POST /v1/chat/completions returns native JSON, or server-sent events when stream is true. The assistant text is in choices[0].message.content.

Unified API (recommended)

New integrations call POST /v1/generations with type=text. The OpenAI-compatible endpoints below remain supported, including streaming.

BASH
curl -X POST https://api.anycap.io/v1/generations \  -H "Authorization: Bearer $ANYCAP_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "type": "text",    "model": "<model from GET /v1/generations/models?type=text>",    "input": { "messages": [{ "role": "user", "content": "hello" }] },    "parameters": { "max_tokens": 128 }  }'
FieldMeaning
input.messages
OpenAI-style messages; the reply is returned in output.
parameters
Chat fields such as temperature and max_tokens.
model
From GET /v1/generations/models?type=text.
The unified text call is synchronous and non-streaming; use POST /v1/chat/completions when you need SSE.
StepMethod and pathSuccess
List authorized modelsGET /v1/models200
GeneratePOST /v1/chat/completions200
JSON
{  "model": "<exact-model>",  "messages": [{ "role": "user", "content": "Say hello in one sentence." }],  "max_tokens": 32,  "stream": false}
  • Idempotency-Key: your own key for the logical call, persisted by you. It may be any opaque string of at most 255 bytes (a readable label such as test-001 is fine); the returned task id is the identity, and when your key is a UUID the task id equals it. The platform scopes keys to your connection, so retrying the same key never submits twice.
  • X-Anycap-Source: pin the authorized source and its model, channel and price.
  • X-Anycap-Channel: select a saved channel slug.
Full text generation document →Use Anycap as a coding agent's model endpoint →