Developer documentation开发者文档

Your first Jiayu API request.发起你的第一个 Jiayu API 请求。

Use a familiar OpenAI-compatible request pattern. Set the base URL, provide your API key, and choose a model that is available in your console.使用熟悉的 OpenAI 兼容请求方式。设置 Base URL、提供 API 密钥,并选择控制台中实际可用的模型。

Quickstart快速开始

Connect in three steps.三步完成接入。

  • Create an account and generate an API key in the console.注册账户,并在控制台生成 API 密钥。
  • Set your OpenAI-compatible client base URL to Jiayu API.将 OpenAI 兼容客户端的 Base URL 设置为 Jiayu API。
  • Choose a model ID that is currently available in your console.选择控制台中当前可用的模型 ID。
BASE URLhttps://api.jiayugate.com/v1

Authentication身份验证

Authenticate with a bearer token.使用 Bearer Token 验证身份。

Send your Jiayu API key in the Authorization header. Keep production keys on your server and never expose them in browser-side code or public repositories.在 Authorization 请求头中发送 Jiayu API 密钥。生产密钥应保存在服务器端,不要暴露在浏览器代码或公共仓库中。

HTTP header
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Endpoints接口端点

Use familiar request paths.使用熟悉的请求路径。

Jiayu API is designed around OpenAI-compatible request patterns. Endpoint support depends on the provider route and model selected in your console.Jiayu API 围绕 OpenAI 兼容请求方式设计。具体端点支持取决于控制台中选择的供应商路由和模型。

POST/v1/chat/completions
POST/v1/responses

Examples代码示例

Send a chat request.发送聊天请求。

curl
curl https://api.jiayugate.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Python

OpenAI SDK
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.jiayugate.com/v1"
)

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Hello"}]
)

Bring your own key自带供应商密钥

Use your own OpenAI, Claude or Gemini account.使用你自己的 OpenAI、Claude 或 Gemini 账户。

BYOK is a separate access mode for users who already have an official provider account. Jiayu authorizes access to the gateway, while the provider authorizes the model and charges usage to your provider account.BYOK 是面向已有官方供应商账户用户的独立接入模式。Jiayu 负责验证网关访问权限,供应商负责验证模型权限,并将用量计入你的供应商账户。

Hosted mode平台托管模式

/v1

Use one Jiayu API key. Available models, balance, and usage are managed in the Jiayu console.只使用一个 Jiayu API 密钥。可用模型、余额和用量均在 Jiayu 控制台中管理。

BYOK

/byok/{provider}

Send a Jiayu API key and your provider key with every request. Model access and billing stay with the provider.每次请求同时发送 Jiayu API 密钥和供应商密钥。模型权限与计费仍由供应商管理。

User workflow用户操作流程

  • Register or log in, then create a Jiayu API key on the API Keys page.注册或登录,然后在“API 密钥”页面创建 Jiayu API 密钥。
  • Create an API key in your own official OpenAI, Anthropic, or Google AI account.在你自己的 OpenAI、Anthropic 或 Google AI 官方账户中创建 API 密钥。
  • Select the matching BYOK base URL below and keep the provider's native request format.选择下方对应的 BYOK Base URL,并保留供应商原生请求格式。
  • Send both credentials from a trusted server and use an exact model ID enabled for your provider account.从可信服务端发送两种凭据,并使用供应商账户中已开通的精确模型 ID。
OpenAIhttps://api.jiayugate.com/byok/openai/v1
Claudehttps://api.jiayugate.com/byok/anthropic
Geminihttps://api.jiayugate.com/byok/gemini/v1
Provider keys are not stored in the Jiayu application database or BYOK access logs, but they necessarily pass through Jiayu's TLS endpoint. Use BYOK only from trusted server-side environments and never expose either key in browser code.供应商密钥不会写入 Jiayu 应用数据库或 BYOK 访问日志,但会经过 Jiayu 的 TLS 端点。请仅在可信服务端环境中使用 BYOK,且不要在浏览器代码中暴露任何密钥。

Availability可用范围

The live catalog is the source of truth.以实时目录显示为准。

The current public catalog lists 41 entries across OpenAI, Anthropic, Google, DeepSeek, GLM, Qwen, and Moonshot. A listed entry is not a claim that every capability has been independently tested. Use the Model Marketplace for exact identifiers, endpoint support, current pricing, and availability.当前公开目录列出 OpenAI、Anthropic、Google、DeepSeek、GLM、Qwen 与 Moonshot 的 41 个模型条目。“已上架”不代表每项能力均已独立实测。精确模型 ID、端点支持、当前价格与可用性以模型市场为准。