API REFERENCE

Images and PDFs

Send inline images and PDFs to compatible models through Chat Completions or Responses.

Choose a compatible model

Model pages list the input types accepted by Tokely. Images use base64 data URLs with image/png, image/jpeg or image/webp. Files use application/pdf. GPT-5.4 Mini supports both examples below.

Use user messages for images and PDFs. Each decoded image or PDF can be up to 10 MiB; the entire JSON request, including base64 encoding, must fit within 16 MiB. A request can include up to 20 images and 4 PDFs, with at most 32 content parts per message. Remote URLs, uploaded file IDs, audio and video input are not supported.

Input and output tokens are charged at the model’s listed rates. Image and PDF processing can consume more tokens than the text in your prompt. Requests require a funded balance.

Read an image

Encode a local image and send it as an image_url content part.

import os, base64
from openai import OpenAI
client = OpenAI(api_key=os.environ["TOKELY_API_KEY"], base_url="https://api.tokely.me/v1")
with open("image.png", "rb") as file:
    image = "data:image/png;base64," + base64.b64encode(file.read()).decode()
response = client.chat.completions.create(
    model="gpt-5.4-mini", max_tokens=1024,
    messages=[{"role":"user","content":[
        {"type":"text","text":"Describe this image."},
        {"type":"image_url","image_url":{"url":image,"detail":"low"}}
    ]}]
)
print(response.choices[0].message.content)

Read a PDF

Responses uses input_file with filename and file_data. Chat Completions uses a file part containing the same filename and file_data fields.

import os, base64
from openai import OpenAI
client = OpenAI(api_key=os.environ["TOKELY_API_KEY"], base_url="https://api.tokely.me/v1")
with open("invoice.pdf", "rb") as file:
    pdf = "data:application/pdf;base64," + base64.b64encode(file.read()).decode()
response = client.responses.create(
    model="gpt-5.4-mini", max_output_tokens=1024, store=False,
    input=[{"role":"user","content":[
        {"type":"input_text","text":"What is the invoice total?"},
        {"type":"input_file","filename":"invoice.pdf","file_data":pdf}
    ]}]
)
print(response.output_text)

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