Skip to content

AI 模型接口

本页面展示 NewBigAI 的 AI 模型相关 API 接口文档,包括对话补全、图片生成、语音处理等接口。

基础信息

  • Base URL: https://newbigai.com
  • 认证方式: Bearer Token(Authorization: Bearer sk-xxx
  • 数据格式: JSON

主要接口

对话补全 (Chat Completions)

http
POST /v1/chat/completions

这是最常用的接口,兼容 OpenAI Chat Completions API 格式。

请求示例:

bash
curl https://newbigai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-你的密钥" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "你是一个有帮助的助手。"},
      {"role": "user", "content": "你好"}
    ],
    "stream": false
  }'

响应示例:

json
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!有什么我可以帮助你的吗?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 15,
    "total_tokens": 35
  }
}

流式输出

设置 stream: true 启用 Server-Sent Events 流式输出:

bash
curl https://newbigai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-你的密钥" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "你好"}],
    "stream": true
  }'

获取模型列表

http
GET /v1/models

返回当前可用的所有模型。

图片生成

http
POST /v1/images/generations
bash
curl https://newbigai.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-你的密钥" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一只在月球上弹吉他的猫",
    "n": 1,
    "size": "1024x1024"
  }'

文本嵌入

http
POST /v1/embeddings
bash
curl https://newbigai.com/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-你的密钥" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "这是一段需要向量化的文本"
  }'

语音转文本

http
POST /v1/audio/transcriptions

文本转语音

http
POST /v1/audio/speech

完整交互式文档

下方提供了基于 OpenAPI 规范的完整交互式 API 文档,你可以查看每个接口的详细参数、请求和响应格式,并直接发起测试请求。

NewBigAI - 稳定快速的 AI 大模型网关