GUIDES

Let the response flow.

Display generated text as it arrives with server-sent events.

Enable streaming

Set stream=true to receive text/event-stream. For Chat Completions, read text from choices[0].delta.content. Some models require streaming and return stream_required for a non-streaming request.

# Use the client configured in Quickstart.
stream = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Tell me a short story."}],
    max_tokens=512,
    stream=True,
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Two endpoints, two event formats

Chat Completions sends data events containing completion chunks and ends with [DONE]. Responses uses typed events such as response.output_text.delta and response.completed. Use an SSE parser or the SDK; network chunks are not always complete events.

Handle interruptions

A connection can close after partial output. Preserve that text and show an interrupted state instead of treating it as complete. Cancel the request when your user stops generation.

Tokely does not automatically retry inference. A retry is a new request and can incur additional usage. SDKs may retry independently; configure that behavior in your client.

EXPLORE DOCUMENTATION

IntroductionConnect your app to AI models through one familiar API. This is your guide to building with Tokely.QuickstartMake your first Tokely request in three steps.API keysConnect securely with a key from your Tokely dashboard.ModelsChoose an available model and use its exact ID in your request.PlaygroundUse the Tokely Playground to test prompts before writing code.Use your existing appConnect an existing OpenAI-compatible application to Tokely.Chat CompletionsGenerate responses from text messages and supported inline images or PDFs.ResponsesUse stateless text and supported multimodal input with the Responses API.EmbeddingsTurn text into vectors for search, RAG, clustering and classification with the OpenAI-compatible /v1/embeddings endpoint.Claude Code and the Messages APIPoint Claude Code or the Anthropic SDK at Tokely. Use the native /v1/messages endpoint with streaming, tools and prompt caching.Images and PDFsSend inline images and PDFs to compatible models through Chat Completions or Responses.Images, video & audioGenerate media with your Tokely API key and account balance.Errors & limitsDiagnose failed requests and keep your integration within service limits.StreamingDisplay generated text as it arrives with server-sent events.Function callingLet a model request a function, then execute it in your application.Structured outputRequest JSON output or a defined schema from a compatible model.Usage & billingModel prices, account balance and output reservations.WebhooksTokely webhook events, HMAC signature verification, delivery retries and replay behavior.
Use Tab to browse results ESC to close