Skip to main content

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 URLhttps://api.tokenreply.com/v1
Direct HTTP endpointhttps://api.tokenreply.com/v1/chat/completions
Authorization headerBearer sk-your-token-here

Which 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

Next steps