快速开始
本指南帮助你在 3 分钟内接入 TokPath Gateway,开始调用 100+ 大模型。
前置要求
- 一个 TokPath 账号 — 前往 www.tokpath.com/dashboard 注册
- 获取 API Key — 在控制台的 API Keys 页面创建
- 选择你喜欢的 SDK 或直接使用 cURL
选择接入方式
TokPath 支持三大原生协议,完全兼容各厂商官方 SDK,无需修改代码即可迁移。
OpenAI SDK(推荐)
直接替换 baseURL 即可,其余代码完全不变。
cURLBash
# UloveGPT API 地址,API Key 在 https://www.ulovegpt.com/dashboard 获取
curl https://www.ulovegpt.com/v1/chat/completions \
-H "Authorization: Bearer <你的 API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-mini",
"messages": [
{"role": "user", "content": "生命的意义是什么?"}
]
}'PythonPython
from openai import OpenAI
client = OpenAI(
# UloveGPT API 地址
base_url="https://www.ulovegpt.com/v1",
# 在 https://www.ulovegpt.com/dashboard 获取
api_key="<你的 API_KEY>"
)
response = client.chat.completions.create(
model="openai/gpt-5.4-mini",
messages=[
{"role": "user", "content": "生命的意义是什么?"}
]
)
print(response.choices[0].message.content)TypeScriptTypescript
import OpenAI from 'openai'
const client = new OpenAI({
// UloveGPT API 地址
baseURL: 'https://www.ulovegpt.com/v1',
// 在 https://www.ulovegpt.com/dashboard 获取
apiKey: '<你的 API_KEY>'
})
async function main() {
const response = await client.chat.completions.create({
model: 'openai/gpt-5.4-mini',
messages: [
{ role: 'user', content: '生命的意义是什么?' }
]
})
console.log(response.choices[0].message.content)
}
main()Anthropic SDK
使用 Anthropic 官方 SDK,只需修改 baseURL 为 TokPath 地址。
cURLBash
# UloveGPT API 地址,API Key 在 https://www.ulovegpt.com/dashboard 获取
curl https://www.ulovegpt.com/anthropic/v1/messages \
-H "x-api-key: <你的 API_KEY>" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "生命的意义是什么?"}
]
}'PythonPython
import anthropic
client = anthropic.Anthropic(
# UloveGPT API 地址
base_url="https://www.ulovegpt.com/anthropic",
# 在 https://www.ulovegpt.com/dashboard 获取
api_key="<你的 API_KEY>"
)
message = client.messages.create(
model="anthropic/claude-sonnet-4.6",
max_tokens=1024,
messages=[
{"role": "user", "content": "生命的意义是什么?"}
]
)
print(message.content[0].text)TypeScriptTypescript
import Anthropic from '@anthropic-ai/sdk'
const client = new Anthropic({
// UloveGPT API 地址
baseURL: 'https://www.ulovegpt.com/anthropic',
// 在 https://www.ulovegpt.com/dashboard 获取
apiKey: '<你的 API_KEY>'
})
async function main() {
const message = await client.messages.create({
model: 'anthropic/claude-sonnet-4.6',
max_tokens: 1024,
messages: [
{ role: 'user', content: '生命的意义是什么?' }
]
})
console.log(message.content[0].text)
}
main()Gemini SDK
使用 Google GenAI SDK,只需设置 TokPath 的 Gemini 代理地址。
cURLBash
curl "https://www.ulovegpt.com/gemini/v1beta/models/google/gemini-3.1-flash-lite-preview:generateContent" \
-H "x-goog-api-key: <你的 API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts": [{"text": "生命的意义是什么?"}]
}]
}'PythonPython
from google import genai
client = genai.Client(
# UloveGPT API 地址
http_options={"base_url": "www.ulovegpt.com"},
# 在 https://www.ulovegpt.com/dashboard 获取
api_key="<你的 API_KEY>"
)
response = client.models.generate_content(
model="google/gemini-3.1-flash-lite-preview",
contents="生命的意义是什么?"
)
print(response.text)TypeScriptTypescript
import { GoogleGenAI } from '@google/genai'
const ai = new GoogleGenAI({
// UloveGPT API 地址
baseUrl: 'https://www.ulovegpt.com/gemini',
// 在 https://www.ulovegpt.com/dashboard 获取
apiKey: '<你的 API_KEY>'
})
async function main() {
const response = await ai.models.generateContent({
model: 'google/gemini-3.1-flash-lite-preview',
contents: '生命的意义是什么?'
})
console.log(response.text)
}
main()