快速开始
创建密钥并在几分钟内获得模型响应。
你需要一个有额度的 Webway 账户和一个 API 密钥。
1. 创建密钥
打开 API 密钥,创建一个密钥并立即复制。完整密钥只显示一次。
export WEBWAY_API_KEY="sk-ww-…"
把密钥保存在 shell 或密钥管理器中,绝不要放进源代码。
2. 发送请求
curl https://api.webway.sh/v1/chat/completions \
-H "Authorization: Bearer $WEBWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.6-terra",
"messages": [
{"role": "user", "content": "Explain this API in one sentence."}
]
}'
答案在 choices[0].message.content 中。
使用 OpenAI SDK
任何支持自定义 base URL 的 OpenAI 客户端都可以使用 Webway。
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.webway.sh/v1",
api_key=os.environ["WEBWAY_API_KEY"],
)
response = client.chat.completions.create(
model="openai/gpt-5.6-terra",
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(response.choices[0].message.content)
不要把完整的 /chat/completions 路径用作 SDK 的 base URL;SDK 会自己加上这段路径。