从第一步,到你的下一步。From your first request to what's next.
从创建密钥到首次调用,为你的工具与应用找到清晰的接入方式。A clear path from creating a key to connecting your tools and applications.
从快速开始读起Read the quick start介绍Introduction
在一个工作空间管理账户、余额、密钥和用量。工具与应用通过对应协议访问服务;选择的接入分组决定可用模型、权限和计费规则。Manage your account, balance, keys and usage in one workspace. Tools and applications connect using their supported protocols. Your access group determines available models, permissions and billing rules.
新手可以先读快速开始,已有客户端的用户可直接进入Start with the quick start guide, or connect an existing client in 教程中心Tutorials。接入线路在. Access routes are available in 工作空间Workspace中查看。.
快速开始Quick start
- 进入工作空间Open workspace。新用户可以在本站开放注册时创建账户。. New users can create an account when registration is open.
- 在In API Keys 中创建密钥,选择与你的工具匹配的接入分组。, create a key and choose an access group that matches your tool.
- 查看Read the 工具接入指南tool setup guide,填写接入地址和 API Key。 and enter your endpoint and API key.
- 完成首次调用后,在After your first request, open 用量明细Usage中查看记录和实际消费。 to review the request and its actual cost.
密钥与权限Keys & permissions
- 01
为工具创建独立 KeyCreate a key for each tool
进入 API Keys,点击创建,名称可填写 Claude Code、Codex 或 Chatbox,便于分别查看用量和停用。Open API Keys and create a key named after its tool, such as Claude Code, Codex, or Chatbox. This makes usage tracking and revocation easier.
- 02
选择分组与模型Choose a group and model
Claude 工具选择支持 Anthropic Messages 的分组;Codex 选择 Responses 分组;普通对话客户端按其支持的协议选择。模型 ID 从模型与价格页面复制。Choose an Anthropic Messages group for Claude tools, a Responses group for Codex, and a matching protocol for chat clients. Copy a model ID from Models & pricing.
- 03
设置额度与有效期Set a spending cap and expiry
按需填写消费额度和有效期。额度填 0 表示不设置 Key 上限,账户余额、订阅、分组权限和平台限额仍然生效。Set a spending cap and expiry as needed. A cap of 0 means no key-specific cap; balance, subscription, group permissions, and platform limits still apply.
- 04
复制到自己的工具Copy the key into your tool
将创建结果中的完整密钥替换 YOUR_API_KEY,模型替换 YOUR_MODEL_ID。不要复制列表里的掩码,也不要保留占位符。Replace YOUR_API_KEY with the complete created key and YOUR_MODEL_ID with your model. Do not copy a masked display value or leave placeholders unchanged.
工具使用用户 API Key。网页登录密码、验证码、登录 Token、管理员 Key 和上游账号凭据均不能作为这里的示例密钥。Use your user API key in tools. Login passwords, verification codes, session tokens, administrator keys, and upstream credentials are not suitable here.
请把密钥保存在自己的设备或密钥管理工具中。配置文件含真实 Key 时不要共享、提交到仓库或截图;泄露后立即停用并重新创建。Store keys on your device or in a secrets manager. Do not share, commit, or screenshot files with real keys. Revoke and replace an exposed key immediately.
需要轮换密钥时,先创建新密钥并更新工具配置,再删除旧密钥。To rotate a key, create a new one and update your tool before deleting the old key.
接入地址Endpoints
下表与代码使用本站默认示例地址。登录后可查看地区线路;使用其他线路时,请手动替换示例中的根地址或 /v1 地址,代码不会随地区选择自动改变。The table and code use the default example endpoint. Sign in to view regional routes. For another route, replace the root or /v1 URL manually; selecting a region does not update the code.
| 工具 / 客户端Tool / client | 填写的地址URL to enter | 请求路径Request path |
|---|---|---|
| Claude Code / Claude Desktop | https://newapi.world根地址,不加 /v1Root URL, without /v1 | /v1/messages |
| Codex / OpenAI SDK | https://newapi.world/v1Base URL 带 /v1Include /v1 in the base URL | /v1/responses |
| ChatGPT / Codex Desktop | https://newapi.world/v1适用于支持自定义提供方的 Codex 工作区For Codex workspaces with custom provider support | /v1/responses |
| Chatbox · GPT | https://newapi.worldHost 与完整 Path 分开填写Enter the host and full path separately | /v1/chat/completions |
| Chatbox · Claude | https://newapi.world选择 Anthropic 兼容协议Select the Anthropic-compatible protocol | /v1/messages |
| Gemini CLI | https://newapi.world根地址,由工具拼接路径Root URL; the tool appends the path | /v1beta/… |
Base URL 是基础地址,不是完整请求地址。不要填控制台登录页、/api/v1 管理接口,或拼出 /v1/v1。各协议是否可用,以所选分组实际开放的能力为准。Use a base URL, not a complete request endpoint. Avoid login pages, /api/v1 management endpoints, and duplicate /v1/v1 paths. Available protocols depend on your access group.
工具与 CLI 快速上手Tools & CLI quick start
原有 9 类工具指南都在教程中心,包含 Claude Code、Codex、Gemini CLI、CC Switch、Cursor、Continue.dev、Aider、LobeChat 和 Chatbox。All nine tool guides are in Tutorials: Claude Code, Codex, Gemini CLI, CC Switch, Cursor, Continue.dev, Aider, LobeChat and Chatbox.
调用示例API examples
先将 API Key 保存到当前终端的环境变量。将示例中的占位符替换为你的真实密钥和模型 ID。Save your API key as an environment variable in the current terminal. Replace placeholders with your key and model ID.
macOS / Linux
export PORTAL_API_KEY="YOUR_API_KEY"Windows PowerShell
$env:PORTAL_API_KEY = "YOUR_API_KEY"以下 cURL 命令使用 Bash / Zsh 语法。Windows 可用 WSL / Git Bash,或运行后面的 Python 示例;PowerShell 设置的环境变量可供同一终端启动的 Python 使用。The cURL examples use Bash / Zsh syntax. On Windows, use WSL / Git Bash or the Python example. Python launched from the same PowerShell session inherits its environment variables.
OpenAI Responses · cURL
curl "https://newapi.world/v1/responses" \
-H "Authorization: Bearer $PORTAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","input":"Hello!"}'Python SDK
使用Run pip install openai 安装 SDK 后运行: to install the SDK, then run:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PORTAL_API_KEY"],
base_url="https://newapi.world/v1",
)
response = client.responses.create(
model="YOUR_MODEL_ID",
input="Hello!",
)
print(response.output_text)Anthropic Messages · cURL
curl "https://newapi.world/v1/messages" \
-H "Authorization: Bearer $PORTAL_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model":"YOUR_MODEL_ID",
"max_tokens":256,
"messages":[{"role":"user","content":"Hello!"}]
}'基础对话 · Chat CompletionsBasic chat · Chat Completions
以下示例适用于已开放 Chat Completions 协议的分组。先运行基础示例创建These examples require a group that supports Chat Completions. Run the basic example to create client,再按需运行后续片段;Responses 和 Anthropic 分组请使用上方原生协议示例。, then try the snippets below. For Responses or Anthropic groups, use the native protocol examples above.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PORTAL_API_KEY"],
base_url="https://newapi.world/v1",
)
response = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)流式响应 · StreamingStreaming responses
增量读取输出,适合交互式对话。SDK 会处理事件流,空事件无需输出。Read output as it arrives for interactive conversations. The SDK handles the event stream; skip empty events.
stream = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "Write a short poem."}],
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)多模态 · 图片输入Multimodal · Image input
选择支持图片输入的模型,并填写可访问的图片地址。图片大小、格式和计费由模型与分组规则决定。Choose a model that supports image input and provide an accessible image URL. Size, format and billing follow the model and group rules.
response = client.chat.completions.create(
model="YOUR_VISION_MODEL_ID",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Describe this picture."},
{"type": "image_url", "image_url": {"url": "YOUR_IMAGE_URL"}},
],
}],
)
print(response.choices[0].message.content)函数调用 · Tool UseFunction calling · Tool use
模型返回工具调用后,由你的应用验证参数、执行工具,再传回结果。工具不会由门户自动执行。下面的天气结果是示例数据,需要替换为实际服务。When the model requests a tool call, your application validates the arguments, runs the tool and returns the result. The portal does not execute tools. Replace the sample weather data below with a real service.
import json
messages = [{"role": "user", "content": "Weather in Shanghai?"}]
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
response = client.chat.completions.create(
model="YOUR_MODEL_ID", messages=messages, tools=tools,
)
message = response.choices[0].message
messages.append(message.model_dump(exclude_none=True))
for call in message.tool_calls or []:
if call.function.name != "get_weather":
raise ValueError("Unexpected tool")
arguments = json.loads(call.function.arguments)
# Replace this example result with your actual weather service.
result = {"city": arguments["city"], "status": "example_only"}
messages.append({
"role": "tool", "tool_call_id": call.id,
"content": json.dumps(result),
})
answer = client.chat.completions.create(
model="YOUR_MODEL_ID", messages=messages,
)
print(answer.choices[0].message.content)模型选择Choosing a model
在In 模型与价格Models & pricing中确认可用模型 ID,再检查你的密钥分组支持哪种协议。优先根据任务复杂度、响应速度、上下文长度和价格选择。, confirm the model ID and check your key group's protocol. Choose based on task complexity, response speed, context length and price.
- 日常对话与摘要:先用较低成本模型验证质量。Everyday chat and summaries: test quality with a lower-cost model first.
- 复杂代码与推理:比较任务成功率、延迟和总消费。Complex code and reasoning: compare task success, latency and total cost.
- 图片任务:确认模型支持图片输入,再参考多模态示例。Image tasks: confirm image input support, then use the multimodal example.
- 工具调用与 Agent:确认模型和分组均支持工具协议。Tools and agents: check that both the model and group support tool calls.
高级技巧Advanced usage
故障切换 · FallbackFallback models
在应用中准备备选模型,并确认协议和权限一致。平台是否自动切换上游由实际分组配置决定;当前门户不提供自动容灾设置。对可能已经执行或扣费的请求,先确认结果再重试。Prepare fallback models in your application and check compatible protocols and permissions. Automatic upstream failover depends on group configuration; the portal does not configure it. Check the outcome before retrying requests that may already have run or incurred charges.
Prompt Caching
稳定的系统提示和公共上下文适合放在请求前部。支持显式缓存的 Anthropic 分组可以按对应协议设置Place stable system prompts and shared context early in the request. Anthropic groups with explicit caching support can use cache_control;其他模型的缓存行为可能自动处理。命中情况与费用以用量记录为准。; other models may handle caching automatically. Check usage records for cache hits and charges.
超时与重试Timeouts & retries
- 给推理任务预留足够超时,并为流式连接设置合理的空闲时间限制。Allow enough time for inference and set an appropriate idle timeout for streaming connections.
- 遇到 429 时按服务端重试提示或指数退避处理。For 429 responses, follow server retry guidance or use exponential backoff.
- 401 / 403 优先检查密钥、权限和分组,避免重复发送同一错误请求。For 401 or 403 responses, check your key, permissions and group before retrying.
- 5xx 与网络中断先判断请求是否已被执行;有副作用的工具操作需要去重。After 5xx errors or network interruptions, check whether the request ran. Deduplicate tool actions with side effects.
用量与计费Usage & billing
账户总览Account overview展示余额、今日调用与实际消费。 shows your balance, today's requests and actual charges. 用量明细Usage支持按日期与 Key ID 查询使用日志,包括模型、输入和输出 Tokens、缓存读写、缓存命中率、首 Token 时间和实际消费。 supports filtering by date and key ID, with model, input/output tokens, cache reads/writes, cache hit rate, time to first token, and actual cost.
模型页面的官方参考价用于比较。实际账单会结合接入分组、专属倍率、缓存、订阅和其他平台规则计算。Official model prices are provided for comparison. Actual billing includes group rates, custom multipliers, caching, subscriptions and other platform rules.
你可以在Open 充值与余额Top up & balance中查看余额、使用兑换码,以及在平台启用时在线充值和查询订单。 to view your balance, redeem codes, and, when enabled, top up online and check orders.
真实性验证Authenticity verification
带有 TEE 证明的响应可以交给开源验证器核对来源和完整性。普通响应中的模型名或模型自述,不能单独证明真实来源。An open-source verifier can check the provenance and integrity of responses carrying TEE evidence. A model name or self-description alone does not establish provenance.
查看第三方验证入口、材料要求与验证边界View verification tools, required evidence, and limitations →
常见问题Frequently asked questions
404、网页 HTML 或 /v1/v1 怎么处理?How do I fix a 404, HTML response, or duplicated /v1?
检查是否误填门户页面地址、管理接口地址或完整推理路径。Claude Code 使用根地址,Codex 使用 /v1 基础地址;Chatbox 的 Host 和 Path 要一起检查。模型不存在时也可能返回 404,请同时阅读错误消息。Check for a page URL, management endpoint, or full inference path in a base URL field. Claude Code uses the root, Codex uses /v1, and Chatbox splits host and path. A missing model can also return 404; read the error message.
换地区后,同一个 Key 能继续用吗?Can I reuse a key when switching regions?
只有平台明确提供共享账户与密钥的线路才可复用。切换地址不会自动增加分组权限、共享独立站点余额或转换协议;以账户中实际开放的入口为准。Reuse a key only across routes explicitly configured to share accounts and keys. Changing the URL does not grant group access, share balances across independent sites, or convert protocols. Use routes available to your account.
CLI 可以用,桌面客户端为什么不生效?Why does the CLI work but the desktop app does not?
桌面应用可能读不到终端的环境变量。Claude Desktop 要使用第三方推理设置;Codex 桌面工作区读取对应的 config.toml,并需要应用进程可访问密钥。修改后完全退出并重启,再检查模型与提供方。Desktop apps may not inherit terminal variables. Use third-party inference settings for Claude Desktop. Codex needs its config.toml and a key available to the app process. Quit completely and restart, then check the model and provider.
查看桌面配置View desktop setup →连接检查通过,但工具调用失败?Why does a connection check pass but tool use fail?
获取模型列表只说明该接口可访问,不能证明 Responses、流式事件或工具调用兼容。先测试最小对话,再测试所需功能;联系支持时提供时间、模型、线路、状态码和请求 ID,不要提供完整 Key。A model list does not establish Responses, streaming, or tool compatibility. Test a small conversation, then each feature you need. For support, share the time, model, route, status code, and request ID, never the full key.
调用失败,怎样快速定位?How do I troubleshoot a failed request?
先查看状态码和返回消息:401 通常与认证有关,403 与权限有关,429 表示限流,5xx 可能与网关或上游有关。余额与额度限制请以返回消息为准,再检查用量记录、密钥状态和请求地址。Check the status code and message: 401 usually concerns authentication, 403 permissions, 429 rate limits, and 5xx the gateway or upstream. The message explains balance and quota limits. Then check usage records, key status and the endpoint.
可以使用 LangChain / LlamaIndex 吗?Can I use LangChain or LlamaIndex?
选择框架中支持对应协议的适配器,填写本平台地址、模型 ID 和 API Key。先验证基础请求,再接入框架;适配器对 Chat Completions 与 Responses 的支持可能不同。Choose a framework adapter for the required protocol, then set the endpoint, model ID and API key. Verify a basic request first. Adapter support for Chat Completions and Responses may differ.
提示 401 或登录过期,怎么处理?What should I do about a 401 or expired session?
网页登录过期时会引导重新登录。工具调用出现 401 时,请检查工具中配置的 API Key 是否完整、有效,以及接入地址是否正确。An expired website session redirects you to sign in. For a tool's 401 response, check that its API key is complete and valid and the endpoint is correct.
为什么没有可用分组或模型?Why are no groups or models available?
模型和分组由平台权限控制。请检查账户或订阅权益;如果模型价目暂未开放,页面会明确提示。Models and groups depend on your permissions. Check your account or subscription access. The page indicates when the model catalog is unavailable.
为什么 Key 被停用或额度耗尽?Why is my key disabled or at its spending limit?
在 API Keys 页面检查状态、额度和有效期。密钥额度与账户余额分别限制调用,两个条件都需要满足。Check the key's status, spending limit and expiry in API Keys. Both the key limit and account balance must allow the request.
如何在多个工具之间切换?How do I switch between tools?
各工具有自己的接入配置。使用独立密钥和匹配的分组,参考工具接入页面设置。不同协议的地址规则不完全相同。Each tool has its own configuration. Use separate keys and matching groups, following the setup guides. Endpoint paths differ by protocol.