### Clone and Start with Docker Compose Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md Clone the project repository and use Docker Compose to start the New API service. This is the recommended method for quick setup. ```bash git clone https://github.com/QuantumNous/new-api.git cd new-api # Edit docker-compose.yml configuration nano docker-compose.yml # Start the service docker-compose up -d ``` -------------------------------- ### Clone Project and Start with Docker Compose Source: https://github.com/quantumnous/new-api/blob/main/README.ja.md Clone the project repository and use docker-compose to start the services. Edit the docker-compose.yml file before starting. ```bash # プロジェクトをクローン git clone https://github.com/QuantumNous/new-api.git cd new-api # docker-compose.yml 設定を編集 nano docker-compose.yml # サービスを起動 docker-compose up -d ``` -------------------------------- ### Clone and Start New API with Docker Compose Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md Clone the project repository, navigate into the directory, edit the docker-compose.yml file for configuration, and then start the services in detached mode. ```bash git clone https://github.com/QuantumNous/new-api.git cd new-api nano docker-compose.yml docker-compose up -d ``` -------------------------------- ### Clone and Configure Docker Compose Source: https://github.com/quantumnous/new-api/blob/main/README.md Clone the project repository and edit the docker-compose.yml file to configure your deployment. This is the recommended method for getting started. ```bash git clone https://github.com/QuantumNous/new-api.git cd new-api # Edit docker-compose.yml configuration nano docker-compose.yml ``` -------------------------------- ### Run New API with Docker (MySQL) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md Deploy the New API using a Docker command, configured for MySQL. This includes setting the SQL_DSN environment variable for the database connection and mapping port 3000. ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### 启动 Docker Compose 服务 Source: https://github.com/quantumnous/new-api/blob/main/docs/installation/BT.md 在包含配置文件的目录下执行命令以启动容器。 ```bash cd /www/wwwroot/new-api docker-compose up -d ``` -------------------------------- ### Run New API with Docker Commands (SQLite) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md Pull the latest Docker image and run the New API container using SQLite as the database. Data is persisted to a local 'data' directory. ```bash # Pull the latest image docker pull calciumion/new-api:latest # Run with SQLite (default) docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run New API with Docker Commands (SQLite) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md Pull the latest Docker image and run the New API container using SQLite as the default database. Ensure data persistence by mounting a volume. ```bash # Pull the latest image docker pull calciumion/new-api:latest # Using SQLite (default) docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run New API with Docker (SQLite) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md Deploy the New API using a Docker command, specifically configured for SQLite. This command maps port 3000, sets the timezone, and mounts a local data directory. ```bash docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run New API with Docker Commands (MySQL) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md Pull the latest Docker image and run the New API container, configuring it to use a MySQL database. Ensure the SQL_DSN environment variable is correctly set. ```bash # Pull the latest image docker pull calciumion/new-api:latest # Run with MySQL docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run New API with Docker Commands (MySQL) Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md Pull the latest Docker image and run the New API container, configuring it to use a MySQL database. Specify the database connection string via the SQL_DSN environment variable. ```bash # Pull the latest image docker pull calciumion/new-api:latest # Using MySQL docker run --name new-api -d --restart always \ -p 3000:3000 \ -e SQL_DSN="root:123456@tcp(localhost:3306)/oneapi" \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### Run New API with Docker (SQLite Default) Source: https://github.com/quantumnous/new-api/blob/main/README.ja.md Pull the latest Docker image and run the container, mapping ports and volumes. This configuration uses SQLite as the default database. ```bash # 最新のイメージをプル docker pull calciumion/new-api:latest # SQLiteを使用(デフォルト) docker run --name new-api -d --restart always \ -p 3000:3000 \ -e TZ=Asia/Shanghai \ -v ./data:/data \ calciumion/new-api:latest ``` -------------------------------- ### 更新 New API 版本 Source: https://github.com/quantumnous/new-api/blob/main/docs/installation/BT.md 通过拉取最新镜像并重启容器来更新服务。 ```bash # 拉取最新镜像 docker pull calciumion/new-api:latest # 重启容器 docker-compose down && docker-compose up -d ``` -------------------------------- ### 配置数据持久化卷 Source: https://github.com/quantumnous/new-api/blob/main/docs/installation/BT.md 在 docker-compose.yml 中配置卷映射以实现数据持久化。 ```yaml volumes: - ./data:/data ``` -------------------------------- ### OpenAI Compatible Chat Completions Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint provides compatibility with OpenAI's Chat Completions API, allowing users to interact with various AI models using a familiar interface. ```APIDOC ## POST /v1/chat/completions ### Description Creates a chat completion choice based on the provided messages and model. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for generating the completion. - **messages** (array) - Required - A list of messages comprising the conversation so far. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more focused and deterministic. - **stream** (boolean) - Optional - Whether to stream back partial message deltas as they are generated. ### Request Example ```json { "model": "gpt-3.5-turbo", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"} ] } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **object** (string) - Type of object, e.g., `chat.completion`. - **created** (integer) - Unix timestamp of creation. - **model** (string) - The model used for the completion. - **choices** (array) - A list of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The generated message. - **role** (string) - Role of the message sender (e.g., `assistant`). - **content** (string) - The content of the message. - **finish_reason** (string) - The reason the model stopped generating tokens. - **usage** (object) - Usage statistics for the completion. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "gpt-3.5-turbo-0613", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` ``` -------------------------------- ### OpenAI Compatible Chat Completions Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint provides compatibility with OpenAI's Chat Completions API, allowing users to interact with various AI models through a familiar interface. ```APIDOC ## POST /v1/chat/completions ### Description Provides chat completions compatible with the OpenAI API. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for chat completions. - **messages** (array) - Required - An array of message objects representing the conversation. - **temperature** (number) - Optional - Controls randomness. Lower values make output more focused and deterministic. - **stream** (boolean) - Optional - Whether to stream back partial message deltas as they become available. ### Request Example ```json { "model": "gpt-3.5-turbo", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"} ], "temperature": 0.7, "stream": false } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the response. - **object** (string) - Type of object, e.g., `chat.completion`. - **created** (integer) - Unix timestamp of when the response was created. - **model** (string) - The model used for the response. - **choices** (array) - An array of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The message content. - **role** (string) - Role of the message sender (e.g., `assistant`). - **content** (string) - The content of the message. - **finish_reason** (string) - The reason the model stopped generating tokens. - **usage** (object) - Usage statistics for the request. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total number of tokens. #### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "gpt-3.5-turbo-0613", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` ``` -------------------------------- ### 配置 Docker Compose 部署文件 Source: https://github.com/quantumnous/new-api/blob/main/docs/installation/BT.md 使用 docker-compose.yml 定义 New API 服务,需确保 SESSION_SECRET 已替换为自定义随机字符串。 ```yaml version: '3' services: new-api: image: calciumion/new-api:latest container_name: new-api restart: always ports: - "3000:3000" volumes: - ./data:/data environment: - SESSION_SECRET=your_session_secret_here # 请修改为随机字符串 - TZ=Asia/Shanghai ``` -------------------------------- ### 生成随机密钥 Source: https://github.com/quantumnous/new-api/blob/main/docs/installation/BT.md 用于生成 SESSION_SECRET 环境变量所需的随机字符串。 ```bash # 生成 SESSION_SECRET openssl rand -hex 16 # 或使用 Linux 命令 head -c 16 /dev/urandom | xxd -p ``` -------------------------------- ### OpenAI Realtime API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint provides a realtime API session compatible with OpenAI, allowing for continuous data streams. ```APIDOC ## POST /v1/realtime/openai/createrealtimesession ### Description Creates a realtime API session compatible with OpenAI. ### Method POST ### Endpoint /v1/realtime/openai/createrealtimesession ### Parameters #### Request Body - **model** (string) - Required - The model to use for the realtime session. - **messages** (array) - Required - An array of message objects to initiate the session. ### Request Example ```json { "model": "gpt-4", "messages": [ {"role": "user", "content": "Start a realtime conversation."} ] } ``` ### Response #### Success Response (200) - **session_id** (string) - The unique identifier for the realtime session. - **status** (string) - The status of the session (e.g., `active`). #### Response Example ```json { "session_id": "rt-session-12345", "status": "active" } ``` ``` -------------------------------- ### Image Generation API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint allows for image generation, compatible with OpenAI's image API. ```APIDOC ## POST /v1/images/openai/post-v1-images-generations ### Description Generates images based on a text prompt. ### Method POST ### Endpoint /v1/images/openai/post-v1-images-generations ### Parameters #### Request Body - **prompt** (string) - Required - A description of the desired image. - **n** (integer) - Optional - The number of images to generate. - **size** (string) - Optional - The size of the generated images (e.g., `1024x1024`). ### Request Example ```json { "prompt": "A futuristic cityscape at sunset", "n": 1, "size": "1024x1024" } ``` ### Response #### Success Response (200) - **created** (integer) - Unix timestamp of creation. - **data** (array) - An array of image objects. - **url** (string) - The URL of the generated image. #### Response Example ```json { "created": 1678886400, "data": [ {"url": "https://example.com/image.png"} ] } ``` ``` -------------------------------- ### Image Generation API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint allows for image generation using models compatible with OpenAI's image API. ```APIDOC ## POST /v1/images/generations ### Description Generates an image based on a text prompt. ### Method POST ### Endpoint /v1/images/generations ### Parameters #### Request Body - **prompt** (string) - Required - A text description of the desired image. - **n** (integer) - Optional - The number of images to generate. - **size** (string) - Optional - The size of the generated images (e.g., `1024x1024`). ### Response #### Success Response (200) - **created** (integer) - Unix timestamp of creation. - **data** (array) - A list of generated image objects. - **url** (string) - The URL of the generated image. ### Response Example ```json { "created": 1677652288, "data": [ { "url": "https://example.com/image.png" } ] } ``` ``` -------------------------------- ### Audio Speech API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint converts text to speech, compatible with OpenAI's audio API. ```APIDOC ## POST /v1/audio/openai/create-speech ### Description Converts text to speech. ### Method POST ### Endpoint /v1/audio/openai/create-speech ### Parameters #### Request Body - **model** (string) - Required - The model to use for speech synthesis (e.g., `tts-1`). - **input** (string) - Required - The text to synthesize. - **voice** (string) - Optional - The voice to use (e.g., `alloy`, `echo`). ### Request Example ```json { "model": "tts-1", "input": "Hello world!", "voice": "alloy" } ``` ### Response #### Success Response (200) - **audio_content** (binary) - The synthesized speech as audio data. #### Response Example (Binary audio data) ``` -------------------------------- ### Audio Transcription API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint handles audio transcription, compatible with OpenAI's audio API. ```APIDOC ## POST /v1/audio/openai/create-transcription ### Description Transcribes audio into text. ### Method POST ### Endpoint /v1/audio/openai/create-transcription ### Parameters #### Request Body - **file** (file) - Required - The audio file to transcribe. - **model** (string) - Required - The model to use for transcription (e.g., `whisper-1`). - **language** (string) - Optional - The language of the audio (ISO-639-1 format). ### Request Example ```json { "file": "@audio.mp3", "model": "whisper-1", "language": "en" } ``` ### Response #### Success Response (200) - **text** (string) - The transcribed text. #### Response Example ```json { "text": "This is a test transcription." } ``` ``` -------------------------------- ### OpenAI Responses API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint allows users to interact with models that provide responses in the OpenAI Responses format. ```APIDOC ## POST /v1/chat/openai/createresponse ### Description Generates a response using the OpenAI Responses format. ### Method POST ### Endpoint /v1/chat/openai/createresponse ### Parameters #### Request Body - **model** (string) - Required - The model to use. - **messages** (array) - Required - A list of messages. ### Response #### Success Response (200) - **response** (object) - The generated response in OpenAI Responses format. ### Response Example ```json { "response": { "id": "resp-123", "object": "text_completion", "created": 1677652288, "model": "some-model", "choices": [ { "text": "This is a generated response.", "index": 0, "finish_reason": "stop" } ] } } ``` ``` -------------------------------- ### Audio Speech API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint converts text into speech. ```APIDOC ## POST /v1/audio/speech ### Description Converts text to speech. ### Method POST ### Endpoint /v1/audio/speech ### Parameters #### Request Body - **model** (string) - Required - The model to use for speech synthesis. - **input** (string) - Required - The text to convert to speech. - **voice** (string) - Optional - The voice to use for speech synthesis. ### Response #### Success Response (200) - **audio_content** (binary) - The synthesized speech audio content. ### Response Example (Binary audio data would be returned here) ``` -------------------------------- ### Rerank API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint supports reranking functionalities using models like Cohere and Jina. ```APIDOC ## POST /v1/rerank/create-rerank ### Description Performs reranking on a list of documents. ### Method POST ### Endpoint /v1/rerank/create-rerank ### Parameters #### Request Body - **model** (string) - Required - The rerank model to use (e.g., `cohere`, `jina`). - **query** (string) - Required - The query to rank documents against. - **documents** (array) - Required - A list of documents to rerank. - **id** (string) - Required - Document identifier. - **content** (string) - Required - Document content. ### Response #### Success Response (200) - **results** (array) - The reranked results. - **document** (object) - The reranked document. - **id** (string) - Document identifier. - **content** (string) - Document content. - **relevance_score** (number) - The relevance score. - **index** (integer) - The original index of the document. ### Response Example ```json { "results": [ { "document": { "id": "doc-1", "content": "This is the first document." }, "relevance_score": 0.95, "index": 0 }, { "document": { "id": "doc-2", "content": "This is the second document." }, "relevance_score": 0.85, "index": 1 } ] } ``` ``` -------------------------------- ### OpenAI Responses API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint handles responses in the OpenAI Responses format, which may differ from standard chat completions. ```APIDOC ## POST /v1/chat/openai/createresponse ### Description Handles chat completions specifically formatted as OpenAI Responses. ### Method POST ### Endpoint /v1/chat/openai/createresponse ### Parameters #### Request Body - **model** (string) - Required - The model to use. - **messages** (array) - Required - An array of message objects. - **temperature** (number) - Optional - Controls randomness. ### Request Example ```json { "model": "gpt-3.5-turbo", "messages": [ {"role": "user", "content": "Tell me a joke."} ], "temperature": 0.8 } ``` ### Response #### Success Response (200) - **response** (string) - The generated response content. - **finish_reason** (string) - The reason for stopping generation. #### Response Example ```json { "response": "Why don't scientists trust atoms? Because they make up everything!", "finish_reason": "stop" } ``` ``` -------------------------------- ### Audio Transcription API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint provides audio transcription capabilities. ```APIDOC ## POST /v1/audio/transcriptions ### Description Transcribes audio into text. ### Method POST ### Endpoint /v1/audio/transcriptions ### Parameters #### Request Body - **file** (file) - Required - The audio file to transcribe. - **model** (string) - Required - The model to use for transcription. - **language** (string) - Optional - The language of the audio (ISO-639-1 format). ### Response #### Success Response (200) - **text** (string) - The transcribed text. ### Response Example ```json { "text": "This is the transcribed audio content." } ``` ``` -------------------------------- ### Google Gemini Chat API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint allows interaction with Google Gemini models for chat functionalities. ```APIDOC ## POST /v1/chat/gemini/geminirelayv1beta ### Description Relays chat requests to Google Gemini models. ### Method POST ### Endpoint /v1/chat/gemini/geminirelayv1beta ### Parameters #### Request Body - **model** (string) - Required - The Gemini model to use. - **contents** (array) - Required - A list of content parts for the conversation. ### Response #### Success Response (200) - **candidates** (array) - A list of response candidates from the model. - **content** (object) - The content of the candidate response. - **parts** (array) - Parts of the content. - **text** (string) - The text content. - **finish_reason** (string) - The reason for finishing. ### Response Example ```json { "candidates": [ { "content": { "parts": [ { "text": "This is a response from Google Gemini." } ] }, "finish_reason": "STOP" } ] } ``` ``` -------------------------------- ### Embeddings API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint generates embeddings for text, compatible with OpenAI's embeddings API. ```APIDOC ## POST /v1/embeddings/createembedding ### Description Creates embeddings for a given input text. ### Method POST ### Endpoint /v1/embeddings/createembedding ### Parameters #### Request Body - **model** (string) - Required - The model to use for generating embeddings. - **input** (string or array) - Required - The input text or array of texts to get embeddings for. ### Request Example ```json { "model": "text-embedding-ada-002", "input": "The quick brown fox jumps over the lazy dog." } ``` ### Response #### Success Response (200) - **data** (array) - An array of embedding objects. - **embedding** (array) - The embedding vector. - **index** (integer) - The index of the input text. - **model** (string) - The model used. - **usage** (object) - Usage statistics. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **total_tokens** (integer) - Total number of tokens. #### Response Example ```json { "data": [ { "embedding": [ 0.0023064255007047176, -0.009327214477539062, // ... more dimensions ], "index": 0 } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 10, "total_tokens": 10 } } ``` ``` -------------------------------- ### 配置渠道额外参数示例 Source: https://github.com/quantumnous/new-api/blob/main/docs/channel/other_setting.md 展示如何通过 JSON 对象启用强制格式化、思考内容转换并设置代理地址。 ```json { "force_format": true, "thinking_to_content": true, "proxy": "socks5://xxxxxxx" } ``` -------------------------------- ### Rerank API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint supports reranking of documents using models like Cohere and Jina. ```APIDOC ## POST /v1/rerank/create-rerank ### Description Performs reranking of provided documents. ### Method POST ### Endpoint /v1/rerank/create-rerank ### Parameters #### Request Body - **model** (string) - Required - The rerank model to use (e.g., `cohere`, `jina`). - **query** (string) - Required - The query to rank documents against. - **documents** (array) - Required - An array of document objects. - **id** (string) - Required - Unique identifier for the document. - **content** (string) - Required - The content of the document. ### Request Example ```json { "model": "cohere", "query": "best programming languages", "documents": [ {"id": "doc1", "content": "Python is a popular language."}, {"id": "doc2", "content": "Java is widely used in enterprise applications."} ] } ``` ### Response #### Success Response (200) - **results** (array) - An array of reranked results. - **document_id** (string) - The ID of the document. - **relevance_score** (number) - The relevance score of the document. #### Response Example ```json { "results": [ {"document_id": "doc1", "relevance_score": 0.95}, {"document_id": "doc2", "relevance_score": 0.80} ] } ``` ``` -------------------------------- ### Google Gemini Chat API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint provides chat functionality for Google Gemini models. ```APIDOC ## POST /v1/chat/gemini/geminirelayv1beta ### Description Relays chat requests to Google Gemini models. ### Method POST ### Endpoint /v1/chat/gemini/geminirelayv1beta ### Parameters #### Request Body - **model** (string) - Required - The Gemini model to use. - **contents** (array) - Required - An array of content objects representing the conversation. ### Request Example ```json { "model": "gemini-1.5-flash", "contents": [ {"role": "user", "parts": [{"text": "What is the capital of France?"}]} ] } ``` ### Response #### Success Response (200) - **candidates** (array) - An array of candidate responses. - **content** (object) - The content of the candidate response. - **parts** (array) - An array of parts in the content. - **text** (string) - The text of the part. #### Response Example ```json { "candidates": [ { "content": { "parts": [ {"text": "The capital of France is Paris."} ] } } ] } ``` ``` -------------------------------- ### Claude Messages API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint allows interaction with models using the Claude Messages API format. ```APIDOC ## POST /v1/chat/messages ### Description Creates a message completion using the Claude Messages API format. ### Method POST ### Endpoint /v1/chat/messages ### Parameters #### Request Body - **model** (string) - Required - The model to use. - **messages** (array) - Required - A list of messages. ### Response #### Success Response (200) - **id** (string) - Unique identifier for the message. - **type** (string) - Type of message, e.g., `message_delta`. - **role** (string) - Role of the sender. - **content** (array) - Content of the message. - **stop_reason** (string) - The reason the model stopped generating. ### Response Example ```json { "id": "msg-123", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "This is a response from Claude." } ], "stop_reason": "end_turn" } ``` ``` -------------------------------- ### Claude Messages API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_CN.md This endpoint allows interaction with models using the Claude Messages API format. ```APIDOC ## POST /v1/chat/claude/createmessage ### Description Sends messages to Claude models. ### Method POST ### Endpoint /v1/chat/claude/createmessage ### Parameters #### Request Body - **model** (string) - Required - The Claude model to use. - **messages** (array) - Required - An array of message objects. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate. ### Request Example ```json { "model": "claude-3-sonnet-20240229", "messages": [ {"role": "user", "content": "Explain the concept of recursion."} ], "max_tokens": 100 } ``` ### Response #### Success Response (200) - **content** (string) - The response content from the Claude model. - **stop_reason** (string) - The reason the model stopped generating. #### Response Example ```json { "content": "Recursion is a method where the solution to a problem depends on smaller instances of the same problem.", "stop_reason": "end_turn" } ``` ``` -------------------------------- ### Embeddings API Source: https://github.com/quantumnous/new-api/blob/main/README.zh_TW.md This endpoint generates embeddings for text. ```APIDOC ## POST /v1/embeddings ### Description Creates an embedding vector for a given text. ### Method POST ### Endpoint /v1/embeddings ### Parameters #### Request Body - **model** (string) - Required - The model to use for generating embeddings. - **input** (string or array) - Required - The text or list of texts to generate embeddings for. ### Response #### Success Response (200) - **data** (array) - A list of embedding objects. - **embedding** (array) - The embedding vector. - **index** (integer) - The index of the input text. - **model** (string) - The model used. - **usage** (object) - Usage statistics. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **total_tokens** (integer) - Total tokens used. ### Response Example ```json { "data": [ { "embedding": [ 0.0023, -0.0074, 0.0031, // ... more dimensions ], "index": 0 } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 5, "total_tokens": 5 } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.