API 文档
领风算力平台兼容 OpenAI API 格式,可使用任何 OpenAI SDK 直接接入
1. 获取 API Key
登录控制台后,在 API Keys 页面点击「生成新 Key」即可获取。
Key 格式:sk-lf-xxxxxxxxxxxx
Base URL:
https://api.lingfengtoken.com/v12. 发起请求
cURL
bash
curl https://api.lingfengtoken.com/v1/chat/completions \
-H "Authorization: Bearer sk-lf-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你好"}
],
"stream": true
}'Python (OpenAI SDK)
python
from openai import OpenAI
client = OpenAI(
api_key="sk-lf-xxxxxxxxxxxx",
base_url="https://api.lingfengtoken.com/v1"
)
response = client.chat.completions.create(
model="gpt-5.4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你好"}
],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Node.js (OpenAI SDK)
javascript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-lf-xxxxxxxxxxxx',
baseURL: 'https://api.lingfengtoken.com/v1',
});
const stream = await client.chat.completions.create({
model: 'gpt-5.4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: '你好' },
],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}3. 响应格式
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-5.4",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!有什么可以帮你的吗?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 8,
"total_tokens": 23
}
}