Skip to main content

๐Ÿš€ Using Your API Key

This page is dedicated to using an API key you already have. If you do not have one yet, create or refresh it first on the API Key Management page.

Start with this API URL

OpenAI-compatible Base URLhttps://api.tokenreply.com/v1
Raw HTTP endpointhttps://api.tokenreply.com/v1/chat/completions
Authorization headerBearer sk-your-token-here

๐Ÿ’ก Most common setup

If your client asks for a Base URL, OpenAI URL, or API URL, use https://api.tokenreply.com/v1. If it expects a raw HTTP endpoint, use https://api.tokenreply.com/v1/chat/completions.

๐Ÿ’ก About the example model

The examples below use gpt-4o. Replace it with a model your account can call. See the Models page. Free accounts are limited to free and Featured models; see Plans & Tiers.

โš™๏ธ Environment Variables

This is the most universal and safest way to integrate. Many OpenAI-compatible SDKs read these environment variables 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

If you want to verify the API quickly, cURL is the fastest way to start.

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!"}
    ]
  }'

๐Ÿงฉ Other Usage Scenarios

  • Third-Party Apps: configuration details for CherryStudio, OpenCode, and more
  • Base URL & Auth: understand the difference between the base URL, raw endpoints, and the Authorization header
  • Code Examples: see more full snippets and streaming examples

๐Ÿ‘‰ Next Steps