cURL
最小请求
curl https://tommyapi.com/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"messages": [{"role":"user","content":"hello"}]
}'
Python
OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://tommyapi.com/v1",
)
resp = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[{"role":"user","content":"hello"}],
)
print(resp.choices[0].message.content)
JavaScript
Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "your-api-key",
baseURL: "https://tommyapi.com/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "hello" }],
});
console.log(resp.choices[0].message.content);
Anthropic 兼容
Claude / Messages 接口
curl https://tommyapi.com/v1/messages \
-H "x-api-key: your-api-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role":"user","content":"hello"}]
}'