Using your API key
Everything your app or code needs to connect. If you don't have a key yet, create one on the API Key page.
Your connection details
Base URL
https://api.tokenreply.com/v1Direct HTTP endpoint
https://api.tokenreply.com/v1/chat/completionsAuthorization header
Bearer sk-your-token-hereWhich URL goes where
If your app asks for a Base URL, OpenAI URL or API URL, paste https://api.tokenreply.com/v1. If it wants a full endpoint, paste https://api.tokenreply.com/v1/chat/completions.
Pick a model
Replace gpt-4o in the examples with a model ID from the Models page. Plans and tiers shows which models your account can use.
Environment variables
Put your key in environment variables to keep it out of your code. Many OpenAI SDKs read them automatically.
export OPENAI_API_KEY="sk-your-token-here"
export OPENAI_BASE_URL="https://api.tokenreply.com/v1"Python (openai)
Install: pip install openai
from openai import OpenAI
client = OpenAI(
api_key="sk-your-token-here",
base_url="https://api.tokenreply.com/v1"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)Node.js (openai)
Install: npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-your-token-here",
baseURL: "https://api.tokenreply.com/v1"
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }]
});
console.log(response.choices[0].message.content);cURL
The quickest way to check that your key works:
curl https://api.tokenreply.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token-here" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'More ways to connect
- Connect SillyTavern or JanitorAI with the roleplay setup guides
- Set up Cherry Studio, OpenCode and other apps in Third-party apps
- See how the base URL, endpoints and Authorization header fit together in Base URL and authentication
- Find streaming and more in Code examples
Next steps
- Create, rename, refresh or limit your keys in API key management
- Find a model ID on the Models page
- Fix 401, 429 and model errors with FAQ and troubleshooting
