GET STARTED

From key to first response.

Make your first Tokely request in three steps.

01 / Create an API key

Open Sign in and create an account or sign in to your existing account. In Dashboard → API keys, create a key and copy its secret when it is revealed. Keep it on your server, outside your source code.

Check your balance in the dashboard. Your account balance and API key budget must cover the request.

02 / Set up your environment

Store your key in an environment variable using the command for your terminal. Replace the placeholder with the complete secret from your dashboard.

export TOKELY_API_KEY="<YOUR_TOKELY_API_KEY>"

Install your SDK

Python needs Python 3 and pip. JavaScript needs a supported Node.js version and npm. Use the SDK installation command for your chosen language. For cURL, no SDK is needed.

python3 -m pip install openai

03 / Send a request

This example uses gpt-5.4-mini with Chat Completions. Change the model ID to another available model that supports this endpoint.

curl https://api.tokely.me/v1/chat/completions \
  -H "Authorization: Bearer $TOKELY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [{"role": "user", "content": "Hello, Tokely!"}],
    "max_tokens": 1024
  }'

Run your example

For Python, save the Python example above as hello.py. For JavaScript, save the JavaScript example as hello.mjs so Node.js treats it as an ES module. Run it from the directory where you installed the SDK. On Windows, the py launcher can replace python3 if installed. The cURL example runs directly in a macOS/Linux terminal; Python and JavaScript examples also work with the PowerShell environment setting.

Set TOKELY_API_KEY in the same terminal before running the file. Replace the placeholder with your own key, including its sk- prefix. Environment variables are not automatically shared between terminal windows.

python3 hello.py

Know when it worked

Python and JavaScript print the generated text, for example: Hello! How can I help you today? The exact wording changes between requests. cURL prints the JSON response.

This shortened JSON illustrates the shape of a successful response; IDs, content and usage values are examples. Read choices[0].message.content for your answer.

{
  "object": "chat.completion",
  "model": "gpt-5.4-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 10,
    "total_tokens": 22
  }
}

Make it your own

Read generated text from choices[0].message.content and token counts from usage. Next, explore model selection, streaming or function calling.

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