### Gemini Text Generation - With System Instruction Source: https://doc.zhizengzeng.com/doc-6871160 This example shows how to guide the Gemini model's behavior by providing a system instruction. This allows you to define the persona or role of the AI. ```APIDOC ## POST /google/v1beta/models/gemini-2.0-flash:generateContent ### Description Generates text output with a system instruction to guide the model's behavior. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.0-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your Gemini API key. #### Request Body - **system_instruction** (object) - Optional - Defines the system's instructions for the model. - **parts** (array) - Required - An array of instruction parts. - **text** (string) - Required - The system instruction text. - **contents** (array) - Required - An array containing the content parts for the generation request. - **parts** (array) - Required - An array of content parts. - **text** (string) - Required - The text input for the model. ### Request Example ```json { "system_instruction": { "parts": [ { "text": "You are a cat. Your name is Neko." } ] }, "contents": [ { "parts": [ { "text": "Hello there" } ] } ] } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the generated content candidates. - **content** (object) - The generated content. - **parts** (array) - The parts of the generated content. - **text** (string) - The generated text. ``` -------------------------------- ### Default Operation Example Source: https://doc.zhizengzeng.com/doc-3989021 Demonstrates the default behavior for Python and Node.js. ```python ``` ```node ``` ```text ``` -------------------------------- ### Streaming Example Source: https://doc.zhizengzeng.com/doc-3989021 Illustrates streaming capabilities for Python, Node.js, and the return format. ```text ``` ```python ``` ```node ``` ```text ``` -------------------------------- ### Gemini Text Generation - With Generation Configuration Source: https://doc.zhizengzeng.com/doc-6871160 This example demonstrates how to customize generation parameters such as temperature, max output tokens, topP, and topK using the generationConfig object. ```APIDOC ## POST /google/v1beta/models/gemini-2.0-flash:generateContent ### Description Generates text output with custom generation parameters like temperature, max output tokens, topP, and topK. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.0-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your Gemini API key. #### Request Body - **contents** (array) - Required - An array containing the content parts for the generation request. - **parts** (array) - Required - An array of content parts. - **text** (string) - Required - The text input for the model. - **generationConfig** (object) - Optional - Configuration for the generation process. - **stopSequences** (array) - Optional - Sequences that will cause the generation to stop. - **temperature** (number) - Optional - Controls the randomness of the output. Lower values make the output more deterministic. - **maxOutputTokens** (integer) - Optional - The maximum number of tokens to generate. - **topP** (number) - Optional - Controls diversity via nucleus sampling. - **topK** (integer) - Optional - Controls diversity via top-k sampling. ### Request Example ```json { "contents": [ { "parts": [ { "text": "Explain how AI works" } ] } ], "generationConfig": { "stopSequences": [ "Title" ], "temperature": 1.0, "maxOutputTokens": 800, "topP": 0.8, "topK": 10 } } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the generated content candidates. - **content** (object) - The generated content. - **parts** (array) - The parts of the generated content. - **text** (string) - The generated text. ``` -------------------------------- ### Gemini Video Understanding - Generate Content Source: https://doc.zhizengzeng.com/doc-6914663 This example demonstrates how to use the Gemini API to generate content from a video, such as a summary. It shows how to pass a YouTube URL as input. ```APIDOC ## POST /google/v1beta/models/gemini-2.0-flash:generateContent ### Description Generates content from a video input, such as a summary or answers to questions about the video. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.0-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. #### Request Body - **contents** (array) - Required - An array of content parts. - **parts** (array) - Required - An array of content parts. - **text** (string) - Optional - Textual input for the model. - **file_data** (object) - Optional - Data for a file input. - **file_uri** (string) - Required - The URI of the file (e.g., a YouTube URL). ### Request Example ```json { "contents": [{ "parts":[ {"text": "Please summarize the video in 3 sentences."}, { "file_data": { "file_uri": "https://www.youtube.com/watch?v=9hE5-98ZeCg" } } ] }] } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the model's generated content. - **content** (object) - The generated content. - **parts** (array) - An array of content parts. - **text** (string) - The generated text. - **finishReason** (string) - The reason the model stopped generating. - **avgLogprobs** (number) - The average log probabilities of the generated tokens. - **usageMetadata** (object) - Metadata about token usage. - **modelVersion** (string) - The model version used. - **responseId** (string) - A unique ID for the response. #### Response Example ```json { "candidates": [ { "content": { "parts": [ { "text": "Here is a summary of the video in three sentences:\nThis video shows a demo of the Multimodal Live API that lets people build real-time multimodal applications. The AI in the demo is able to summarize a Google Doc, read text from the screen, define words, tell a story, and recall actions. The demonstration ends encouraging people to build with Gemini 2.0 at aistudio.google.com." } ], "role": "model" }, "finishReason": "STOP", "avgLogprobs": -0.8308103673598346 } ], "usageMetadata": { "promptTokenCount": 42474, "candidatesTokenCount": 85, "totalTokenCount": 42559, "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 9 }, { "modality": "VIDEO", "tokenCount": 38740 }, { "modality": "AUDIO", "tokenCount": 3725 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 85 } ] }, "modelVersion": "gemini-2.0-flash", "responseId": "awlaaPKRH6GPmNAP3ZGxmA0" } ``` ``` -------------------------------- ### Gemini Multimodal Input - Image and Text Source: https://doc.zhizengzeng.com/doc-6871160 This example demonstrates how to use multimodal input by combining text with an image. The API can process and understand content from both modalities. ```APIDOC ## POST /google/v1beta/models/gemini-2.0-flash:generateContent ### Description Generates text output using multimodal input, combining text with an image. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.0-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your Gemini API key. #### Request Body - **contents** (array) - Required - An array containing the content parts for the generation request. - **parts** (array) - Required - An array of content parts. - **text** (string) - Optional - The text input for the model. - **inline_data** (object) - Optional - Inline data for media. - **mime_type** (string) - Required - The MIME type of the data (e.g., "image/jpeg"). - **data** (string) - Required - Base64 encoded data of the media. ### Request Example ```json { "contents": [ { "parts": [ { "text": "Tell me about this instrument" }, { "inline_data": { "mime_type": "image/jpeg", "data": "" } } ] } ] } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the generated content candidates. - **content** (object) - The generated content. - **parts** (array) - The parts of the generated content. - **text** (string) - The generated text. ``` -------------------------------- ### Gemini API with URL Context Source: https://doc.zhizengzeng.com/doc-6914785 This example demonstrates how to use the Gemini API with the `url_context` tool to provide URLs as additional context for the model. The model can then retrieve content from these URLs to answer questions or perform comparisons. ```APIDOC ## POST /google/v1beta/models/gemini-2.5-flash:generateContent ### Description Generates content using the Gemini API, incorporating context from provided URLs. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.5-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. #### Request Body - **contents** (array) - Required - An array of content parts to send to the model. - **parts** (array) - Required - An array of parts within the content. - **text** (string) - Required - The text prompt for the model. - **tools** (array) - Required - A list of tools to enable for the model. - **url_context** (object) - Required - Enables the URL context tool. ### Request Example ```json { "contents": [ { "parts": [ {"text": "Compare recipes from YOUR_URL1 and YOUR_URL2"} ] } ], "tools": [ { "url_context": {} } ] } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the model's generated content. - **content** (object) - The generated content. - **parts** (array) - The parts of the generated content. - **text** (string) - The text of the generated part. ``` -------------------------------- ### Gemini API with URL Context and Google Search Grounding Source: https://doc.zhizengzeng.com/doc-6914785 This example shows how to use the Gemini API with both `url_context` and `google_search` tools. This allows the model to retrieve information from specified URLs and also ground its responses using Google Search, providing more comprehensive and up-to-date answers. ```APIDOC ## POST /google/v1beta/models/gemini-2.5-flash:generateContent ### Description Generates content using the Gemini API, incorporating context from provided URLs and grounding responses with Google Search results. ### Method POST ### Endpoint https://api.zhizengzeng.com/google/v1beta/models/gemini-2.5-flash:generateContent ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. #### Request Body - **contents** (array) - Required - An array of content parts to send to the model. - **parts** (array) - Required - An array of parts within the content. - **text** (string) - Required - The text prompt for the model. - **tools** (array) - Required - A list of tools to enable for the model. - **url_context** (object) - Required - Enables the URL context tool. - **google_search** (object) - Required - Enables the Google Search tool for grounding. ### Request Example ```json { "contents": [ { "parts": [ {"text": "Give me three day events schedule based on YOUR_URL. Also let me know what needs to be taken care of considering weather and commute."} ] } ], "tools": [ { "url_context": {} }, { "google_search": {} } ] } ``` ### Response #### Success Response (200) - **candidates** (array) - Contains the model's generated content. - **content** (object) - The generated content. - **parts** (array) - The parts of the generated content. - **text** (string) - The text of the generated part. ``` -------------------------------- ### 示例代码 - 函数调用 Source: https://doc.zhizengzeng.com/doc-3990060 Example code demonstrating how to utilize the function calling capability of the API. ```APIDOC ## POST /chat/completions (Function Calling) ### Description Enables the model to call functions based on the input prompt and provided function definitions. ### Method POST ### Endpoint /chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use. - **messages** (array) - Required - The conversation history. - **tools** (array) - Required - A list of tools (functions) the model can call. - **type** (string) - Required - The type of tool, e.g., 'function'. - **function** (object) - Required - The function definition. - **name** (string) - Required - The name of the function. - **description** (string) - Optional - A description of the function. - **parameters** (object) - Required - The parameters the function accepts. ### Request Example ```json { "model": "gpt-4", "messages": [ {"role": "user", "content": "What is the weather in Boston?"} ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } } ], "tool_choice": "auto" } ``` ### Response #### Success Response (200) - **choices** (array) - **message** (object) - **role** (string) - Role of the assistant. - **tool_calls** (array) - A list of tool calls the model decided to make. - **id** (string) - The ID of the tool call. - **type** (string) - The type of the tool call ('function'). - **function** (object) - **name** (string) - The name of the function to call. - **arguments** (string) - The arguments to pass to the function, as a JSON string. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "tool_calls": [ { "id": "call_abc123", "type": "function", "function": { "name": "get_current_weather", "arguments": "{\"location\": \"Boston, MA\", \"unit\": \"celsius\"}" } } ] } } ] } ``` ``` -------------------------------- ### Generate Video using Veo 2 Source: https://doc.zhizengzeng.com/doc-6939249 This example demonstrates how to use curl to send a POST request to the predictLongRunning endpoint to generate a video based on a text prompt. It also shows how to obtain the operation name to check the status and eventually download the video. ```APIDOC ## POST /google/v1beta/models/veo-2.0-generate-001:predictLongRunning ### Description Generates a video from a text prompt using the Veo 2 model. ### Method POST ### Endpoint `https://api.zhizengzeng.com/google/v1beta/models/veo-2.0-generate-001:predictLongRunning` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. #### Request Body - **instances** (array) - Required - An array containing the prompt for video generation. - **prompt** (string) - Required - The text description for the video. - **parameters** (object) - Optional - Parameters for video generation. - **aspectRatio** (string) - Optional - The desired aspect ratio of the video (e.g., "16:9"). - **personGeneration** (string) - Optional - Controls person generation (e.g., "dont_allow"). ### Request Example ```bash curl "https://api.zhizengzeng.com/google/v1beta/models/veo-2.0-generate-001:predictLongRunning?key=${ZZZ_API_KEY}" \ -H "Content-Type: application/json" \ -X "POST" \ -d '{ "instances": [{ "prompt": "Panning wide shot of a calico kitten sleeping in the sunshine" } ], "parameters": { "aspectRatio": "16:9", "personGeneration": "dont_allow" } }' ``` ### Response #### Success Response (200) - **name** (string) - The operation name used to track the video generation status. #### Response Example ```json { "name": "operations/883wikdz2kcw" } ``` ## GET /google/v1beta/models/{model}/operations/{operationId} ### Description Checks the status of a long-running video generation operation. ### Method GET ### Endpoint `https://api.zhizengzeng.com/google/v1beta/models/veo-2.0-generate-001/operations/{operationId}` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. #### Path Parameters - **operationId** (string) - Required - The ID of the operation to check. ### Response #### Success Response (200) - **done** (boolean) - Indicates if the operation is complete. - **error** (object) - Contains error details if the operation failed. - **response** (object) - Contains the result if the operation is successful. #### Response Example ```json { "done": true, "response": { "result": { "videoUri": "https://api.zhizengzeng.com/google/v1beta/files/axiona1d5apd:download?alt=media&key=${ZZZ_API_KEY}" } } } ``` ## GET /google/v1beta/files/{fileId}:download ### Description Downloads the generated video file. ### Method GET ### Endpoint `https://api.zhizengzeng.com/google/v1beta/files/{fileId}:download` ### Parameters #### Query Parameters - **alt** (string) - Required - Set to "media" to download the file. - **key** (string) - Required - Your API key. #### Path Parameters - **fileId** (string) - Required - The ID of the file to download. ### Response #### Success Response (200) - The response will be the video file content. ``` -------------------------------- ### Chat Completions (PHP Example) Source: https://doc.zhizengzeng.com/doc-3989793 This snippet demonstrates how to use the 智增增 API to perform chat completions using PHP. It includes setting up headers, defining messages, and making a POST request to the chat completions endpoint. ```APIDOC ## POST /v1/chat/completions ### Description Sends a request to the chat completions endpoint to get a response from the AI model. ### Method POST ### Endpoint https://api.zhizengzeng.com/v1/chat/completions ### Parameters #### Request Body - **user** (string) - Required - The user's identifier. - **messages** (array) - Required - An array of message objects, where each object has a 'role' and 'content'. - **role** (string) - Required - The role of the message sender (e.g., 'user'). - **content** (string) - Required - The content of the message. ### Request Example ```php // Set request headers $api_secret_key = 'xxxxxx'; // Your api_secret_key $headers = array( "Content-Type: application/json", "Authorization: Bearer " . $api_secret_key ); // Set request parameters $params = array(); $params['user'] = '张三'; { $one = ["role" => 'user', "content" => "1+100="]; $messages = array(); $messages[] = $one; $params['messages'] = $messages; } // Call the request $cburl = 'https://api.zhizengzeng.com/v1/chat/completions'; $chatgpt_resp = Tool::_request('post', $cburl, $params, $headers); $data = json_decode($chatgpt_resp, true); ``` ### Response #### Success Response (200) - **content** (string) - The response from the AI model. #### Response Example ```json { "response_content": "101" } ``` ### Tool Function `_request` Description This static method handles making HTTP requests. - **Parameters**: - `method` (string): The HTTP method ('get' or 'post'). - `url` (string): The URL to request. - `data` (array|json): The data to send with POST requests. - `headerArray` (array): An array of HTTP headers. - `ssl` (bool): Whether to enable SSL verification (defaults to false). - **Returns**: - `string`: The response from the server, or `false` on error. ``` -------------------------------- ### Curl: Example API Request Source: https://doc.zhizengzeng.com/doc-4133377 This curl command shows how to make a request to the chat completions endpoint, including necessary headers for content type and authorization. It demonstrates the expected format for messages. ```curl curl -H "Content-Type: application/json" -H "Authorization: Bearer 你在智增增的key" -XPOST https://api.zhizengzeng.com/v1/chat/completions -d ‘{“messages”: [{“role”:”user”,”content”:”请介绍一下你自己”}]}’ | iconv -f utf-8 -t utf-8 ``` -------------------------------- ### MiniMax Image Generation using Zizengzeng API Source: https://doc.zhizengzeng.com/doc-7974615 This snippet demonstrates how to adapt official MiniMax image generation examples to work with the Zizengzeng platform. It highlights the specific changes needed for the API key and base URL. ```APIDOC ## MiniMax Image Generation with Zizengzeng API ### Description This section details how to use the Zizengzeng platform's API to access MiniMax's image generation capabilities. It requires modifying your API key and the base URL to point to the Zizengzeng service. ### Method POST ### Endpoint `https://api.zhizengzeng.com/minimax/v1/images/generations` ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt to generate images from. - **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) - **data** (array) - A list of generated image objects. - **url** (string) - The URL of the generated image. #### Response Example ```json { "data": [ { "url": "https://api.zhizengzeng.com/images/generated_image.png" } ] } ``` ### Notes - Replace `"zzz_api_key"` with your actual `ZZZ_API_KEY` from the Zizengzeng platform. - The `base_url` should be set to `https://api.zhizengzeng.com/minimax`. ``` -------------------------------- ### Making a Chat Completion Request with cURL Source: https://doc.zhizengzeng.com/doc-3950885 This example demonstrates how to make a POST request to the chat completions API using cURL, including necessary headers for content type and authorization, and a JSON payload with the messages array. ```bash curl -H "Content-Type: application/json" -H "Authorization: Bearer 你在智增增的key" -XPOST https://api.zhizengzeng.com/v1/chat/completions -d '{"messages": [{"role":"user","content":"请介绍一下你自己"}]}' | iconv -f utf-8 -t utf-8 ``` -------------------------------- ### Chat Completions API (curl example) Source: https://doc.zhizengzeng.com/doc-3989763 This snippet demonstrates how to use the Chat Completions API endpoint via curl to interact with a chat model. It shows how to send a conversation history and a new user message to get a response. ```APIDOC ## POST /v1/chat/completions ### Description This endpoint allows you to interact with chat models by providing a conversation history and receiving a model-generated response. It's suitable for building conversational AI applications. ### Method POST ### Endpoint https://api.zhizengzeng.com/v1/chat/completions ### Parameters #### Headers - **Content-Type**: application/json - Required - **Authorization**: Bearer $api_secret_key - Required #### Request Body - **messages** (array) - Required - An array of message objects, where each object has a `role` (user, assistant, or system) and `content` (the message text). ### Request Example ```json { "messages": [ {"role":"user","content":"请介绍一下你自己"}, {"role":"assistant","content":"您好,我是小一机器人。我能够与人对话互动,回答问题,协助创作,高效便捷地帮助人们获取信息、知识和灵感。"}, {"role":"user","content": "1+100="} ] } ``` ### Response #### Success Response (200) - The response will be a JSON object containing the model's reply, typically including the message content and other metadata. ``` -------------------------------- ### Create Assistant Source: https://doc.zhizengzeng.com/doc-3990090 Demonstrates how to create a new assistant with a specified name, instructions, tools, and model. The API key and base URL are configured using environment variables or direct assignment. ```APIDOC ## Create Assistant ### Description Creates a new assistant with a specified name, instructions, tools, and model. Requires API key and base URL configuration. ### Method POST ### Endpoint /v1/assistants ### Parameters #### Request Body - **name** (string) - Required - The name of the assistant. - **instructions** (string) - Required - Instructions for the assistant. - **tools** (array) - Required - A list of tools the assistant can use, e.g., `[{"type": "code_interpreter"}]`. - **model** (string) - Required - The model to use for the assistant, e.g., `gpt-4-1106-preview`. ### Request Example ```python from openai import OpenAI API_SECRET_KEY = "YOUR_API_KEY" BASE_URL = "https://api.zhizengzeng.com/v1/" client = OpenAI(api_key=API_SECRET_KEY, base_url=BASE_URL) assistant = client.beta.assistants.create( name="Math Tutor", instructions="You are a personal math tutor. Write and run code to answer math questions.", tools=[{"type": "code_interpreter"}], model="gpt-4-1106-preview" ) print(assistant) ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the assistant. - **name** (string) - The name of the assistant. - **instructions** (string) - The instructions provided to the assistant. - **tools** (array) - The tools available to the assistant. - **model** (string) - The model used by the assistant. #### Response Example ```json { "id": "asst_abc123", "name": "Math Tutor", "instructions": "You are a personal math tutor. Write and run code to answer math questions.", "tools": [ { "type": "code_interpreter" } ], "model": "gpt-4-1106-preview" } ``` ``` -------------------------------- ### Get video generation results Source: https://doc.zhizengzeng.com/doc-8240325 Retrieves the results of a video generation request using the provided request ID. This endpoint corresponds to the official xAI API for getting video generation status. ```APIDOC ## GET /xai/v1/videos/{request_id} ### Description Gets the results of a video generation request. ### Method GET ### Endpoint https://api.zhizengzeng.com/xai/v1/videos/{request_id} ### Parameters #### Path Parameters - **request_id** (string) - Required - The ID of the video generation request. ### Response #### Success Response (200) (No specific response details provided in the source) ``` -------------------------------- ### Example Response with Deep Thinking Output Source: https://doc.zhizengzeng.com/doc-6889065 This is an example of a response from the Messages API when deep thinking is enabled. The response includes a 'thinking' block detailing the model's internal reasoning process before the final text output. ```json { "id": "msg_01WDr8tS3qFLr6ynZxcLtfkX", "type": "message", "role": "assistant", "model": "claude-3-7-sonnet-20250219", "content": [ { "type": "thinking", "thinking": "The user has sent a simple \"Hello, world\" message, which is a common first greeting or test message. This is often used as the first program people write when learning a new programming language, but here it's just being used as a greeting.\n\nI should respond with a friendly greeting and perhaps indicate my readiness to assist with whatever they might need.", "signature": "ErUBCkYIBBgCIkAFZawd/fZNLEeoI82a/lO4OqoZ9MjgNWOoj/deBqL2j2asb2vQW+1NPjgBaNjEzGu7mXRCmzTlrAoz/zdoJ+wdEgy3XrZeI66CzJwTGkMaDPZCb8P51389U6JlwCIwVv1tZE13Oo5dofBvjbX9Gjf2Mpl3lcRFZHgm/M9HY4Fw+tEDaU2MDpKFn3ecgPoJKh3Xqmj0/1dDo8Q+yLetQUT719lxNuSuQBU0dFrvzBgC" }, { "type": "text", "text": "Hello! It's nice to meet you. I'm an AI assistant ready to help with information, answer questions, or just chat. How are you doing today, and is there something specific I can help you with?" } ], "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 38, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0, "output_tokens": 129, "service_tier": "standard" } } ``` -------------------------------- ### 创建视频 Source: https://doc.zhizengzeng.com/doc-7555009 使用提供的API密钥和基础URL,调用`client.videos.create`方法来创建视频。此方法接受一个`prompt`参数来描述视频内容。 ```python API_SECRET_KEY = "你的智增增获取的api_key"; BASE_URL = "https://api.zhizengzeng.com/v1"; #智增增的base_url # create_video def create_video(): client = OpenAI(api_key=API_SECRET_KEY, base_url=BASE_URL) resp = client.videos.create( prompt="A calico cat playing a piano on stage", ) print(resp) return resp.id ``` -------------------------------- ### 下载视频 API Source: https://doc.zhizengzeng.com/doc-7555008 使用 GET 请求下载生成的视频。智增增接口地址与 OpenAI 官方接口地址类似,仅域名不同。 ```HTTP GET https://api.zhizengzeng.com/v1/videos/{video_id}/content ``` -------------------------------- ### 查询视频 API Source: https://doc.zhizengzeng.com/doc-7555008 使用 GET 请求查询视频的状态或信息。智增增接口地址与 OpenAI 官方接口地址类似,仅域名不同。 ```HTTP GET https://api.zhizengzeng.com/v1/videos/{video_id} ``` -------------------------------- ### Create assistant Source: https://doc.zhizengzeng.com/doc-7762834 Create an assistant with a model and instructions. ```APIDOC ## Assistants Official documentation: https://platform.openai.com/docs/api-reference/assistants/createAssistant ### Create assistant Create an assistant with a model and instructions. ``` -------------------------------- ### 示例代码 - translation(识别并翻译成英文) Source: https://doc.zhizengzeng.com/doc-3990060 Example code for translating audio input into English text. ```APIDOC ## POST /audio/translations ### Description Translates spoken audio into English text. ### Method POST ### Endpoint /audio/translations ### Parameters #### Request Body - **file** (file) - Required - The audio file to translate. - **model** (string) - Required - The model to use for translation (e.g., 'whisper-1'). ### Request Example ``` curl -X POST "https://api.zhizengzeng.com/v1/audio/translations" \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "file=@/path/to/audio.mp3" \ -F "model=whisper-1" ``` ### Response #### Success Response (200) - **text** (string) - The translated English text. #### Response Example ```json { "text": "This is the English translation of the audio." } ``` ``` -------------------------------- ### 检查视频是否完成 Source: https://doc.zhizengzeng.com/doc-7555009 在提交视频创建任务后,需要一段时间来执行。使用`client.videos.retrieve`方法,传入视频ID来检查视频的处理状态。视频的完成时间取决于Prompt的复杂度、当前任务队列以及OpenAI的算力。 ```python API_SECRET_KEY = "你的智增增获取的api_key"; BASE_URL = "https://api.zhizengzeng.com/v1"; #智增增的base_url def retrieve(bid): client = OpenAI(api_key=API_SECRET_KEY, base_url=BASE_URL) resp = client.videos.retrieve( "video_123", ) print(resp) return resp.id ``` -------------------------------- ### 示例代码 - audio_transcriptions(语音识别) Source: https://doc.zhizengzeng.com/doc-3990060 Provides example code for performing audio transcription using the API. ```APIDOC ## POST /audio/transcriptions ### Description Transcribes spoken audio into text. ### Method POST ### Endpoint /audio/transcriptions ### Parameters #### Request Body - **file** (file) - Required - The audio file to transcribe (e.g., mp3, wav). - **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). - **prompt** (string) - Optional - An optional text to guide the transcription process. ### Request Example ``` curl -X POST "https://api.zhizengzeng.com/v1/audio/transcriptions" \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "file=@/path/to/audio.mp3" \ -F "model=whisper-1" ``` ### Response #### Success Response (200) - **text** (string) - The transcribed text. #### Response Example ```json { "text": "This is a test audio transcription." } ``` ``` -------------------------------- ### 示例代码 - 流式示例stream Source: https://doc.zhizengzeng.com/doc-3990060 Provides an example for handling streaming responses from the API, useful for real-time applications. ```APIDOC ## POST /chat/completions (Streaming) ### Description Receives chat completions in a streaming format, allowing for real-time display of responses. ### Method POST ### Endpoint /chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for the chat completion. - **messages** (array) - Required - The conversation history. - **stream** (boolean) - Required - Set to `true` to enable streaming. ### Request Example ```json { "model": "gpt-3.5-turbo", "messages": [ {"role": "user", "content": "Tell me a short story."} ], "stream": true } ``` ### Response #### Success Response (200) Responses are streamed as Server-Sent Events (SSE). Each event is a JSON object containing a chunk of the response. - **choices** (array) - **delta** (object) - **content** (string) - The content of the current message chunk. #### Response Example (SSE format) ``` data: {"choices": [{"delta": {"content": "Once upon a time"}}]} data: {"choices": [{"delta": {"content": ", in a land far, far away"}}]} data: {"choices": [{"delta": {"content": ", there lived a brave knight."}}]} data: [DONE] ``` ``` -------------------------------- ### 启动 Gemini CLI 并提问 Source: https://doc.zhizengzeng.com/doc-7018533 配置完成后,直接在终端启动 Gemini CLI。它将自动使用您的 zzz API Key 连接到 Gemini 模型,无需手动认证。 ```bash gemini ``` ```bash You: >> 编写一个python函数,计算斐波那契数列 ``` -------------------------------- ### Create Chat Completion Source: https://doc.zhizengzeng.com/doc-3989021 Creates a model response for the given chat conversation. This is a basic example of a request. ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "gpt-3.5-turbo-0125", "system_fingerprint": "fp_44709d6fcb", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "\n\nHello there, how may I assist you today?", }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 } } ``` -------------------------------- ### 获取batch结果 Source: https://doc.zhizengzeng.com/doc-4445529 使用Python下载batch任务的结果文件。结果文件包含处理后的内容。 ```python API_SECRET_KEY = "你的智增增获取的api_key"; BASE_URL = "https://api.zhizengzeng.com/v1"; #智增增的base_url def get_result(fid): client = OpenAI(api_key=API_SECRET_KEY, base_url=BASE_URL) content = client.files.content(fid) print(content.text); ``` -------------------------------- ### Modify fine-tuned model API Response Source: https://doc.zhizengzeng.com/doc-4696672 This is an example response for modifying a fine-tuned model. It confirms the operation performed on the specified fine-tuned model. ```json { "object": "fine_tuning.job", "id": "ft:abc", "model": "gpt-3.5-turbo-0125", "created_at": 1614807352, "fine_tuned_model": "ft:abc", "created_at": 1111 } ``` -------------------------------- ### OpenAI 官方SDK - Fine Tuning 示例 Source: https://doc.zhizengzeng.com/doc-7762827 使用OpenAI官方SDK进行模型微调。 ```Python from openai import OpenAI client = OpenAI( base_url="https://api.zhizengzeng.com/v1" ) response = client.fine_tuning.jobs.create( training_file="file-xxxxXXxXXxXxXXxXxXXxX", model="gpt-3.5-turbo", ) ``` -------------------------------- ### 下载视频 Source: https://doc.zhizengzeng.com/doc-7555009 视频处理完成后,可以通过下载结果文件来获取视频内容。使用`client.videos.download_content`方法,传入视频ID来下载视频文件。 ```python API_SECRET_KEY = "你的智增增获取的api_key"; BASE_URL = "https://api.zhizengzeng.com/v1"; #智增增的base_url def download_content(fid): client = OpenAI(api_key=API_SECRET_KEY, base_url=BASE_URL) response = client.videos.download_content( video_id="video_123", ) print(response) content = response.read() print(content) ``` -------------------------------- ### Query Video Generation Task Source: https://doc.zhizengzeng.com/doc-8193463 Use this endpoint to query the status of a video generation task using its task ID. It requires a GET request to the specified URL. ```http GET https://api.zhizengzeng.com/kuaishou/v1/videos/omni-video/{task_id} ``` -------------------------------- ### 安装openai的Node.js库 Source: https://doc.zhizengzeng.com/doc-3989806 使用npm安装openai的Node.js库。此库用于与OpenAI兼容的API进行交互。 ```bash npm install openai ``` -------------------------------- ### 流式示例stream Source: https://doc.zhizengzeng.com/doc-3990068 Demonstrates how to use the 智增增 API for streaming chat responses. This example uses the OpenAI Python SDK, configured with the provided API key and base URL. ```APIDOC ## 流式示例stream ### Description This example shows how to receive streaming chat responses from the 智增增 API. It utilizes the `openai` Python library, configured with your specific API key and the base URL. ### Method POST (Implicitly via `openai.ChatCompletion.create`) ### Endpoint `/v1/chat/completions` (Implicitly used by the SDK) ### Parameters #### Request Body (for `openai.ChatCompletion.create`) - **model** (string) - Required - The model to use for chat completion (e.g., "gpt-3.5-turbo"). - **messages** (array) - Required - A list of message objects, where each object has a `role` (user/assistant/system) and `content`. - **stream** (boolean) - Required - Set to `true` to enable streaming responses. ### Request Example ```python import os import openai API_SECRET_KEY = "xxxxx"; # Replace with your 智增增 API key BASE_URL = "https://api.zhizengzeng.com/v1" def stream_chat(prompt: str): openai.api_key = API_SECRET_KEY openai.api_base = BASE_URL for chunk in openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}], stream=True, ): content = chunk["choices"][0].get("delta", {}).get("content") if content is not None: print(content) if __name__ == '__main__': stream_chat("圆周率的前10位"); ``` ### Response Streaming chunks of text content as they are generated by the model. ``` -------------------------------- ### HelloWord-第一个示例 Source: https://doc.zhizengzeng.com/doc-3979939 这是一个简单的Hello World示例,演示如何使用智增增API进行基本调用。用户需要先登录智增增获取API Key和URL,然后配置base_url进行代码编写。 ```APIDOC ## HelloWord-第一个示例 ### Description 这是一个简单的Hello World示例,演示如何使用智增增API进行基本调用。用户需要先登录智增增获取API Key和URL,然后配置base_url进行代码编写。 ### Steps 1. 使用手机号登录智增增,获取并复制API Key和URL。 2. 编写代码,配置base_url为 `https://api.zhizengzeng.com/v1`。 ### Notes - 请注意,base_url可能需要根据具体说明进行灵活变化。 ```