TokenPilotAPI documentation
English简体中文繁體中文
Console ↗

Quickstart

Make your first request to an available model.

Create a key in the console. Set TOKENPILOT_API_KEY locally, then list the models the key can access. Replace REPLACE_WITH_MODEL_ID in the examples with an ID from that response.

Create an API key

1. Set your key

export TOKENPILOT_API_KEY='replace-with-your-key'  # bash / zsh
# PowerShell: $env:TOKENPILOT_API_KEY = 'replace-with-your-key'

2. List models

curl "https://api.tokentpilot.com/v1/models" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY"

3. Send a request

curl "https://api.tokentpilot.com/v1/chat/completions" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","messages":[{"role":"user","content":"Reply in one sentence."}]}'

Python SDK

python -m pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.tokentpilot.com/v1",
    api_key=os.environ["TOKENPILOT_API_KEY"],
)
reply = client.chat.completions.create(
    model="REPLACE_WITH_MODEL_ID",
    messages=[{"role": "user", "content": "Say hello."}],
)
print(reply.choices[0].message.content)