### Minimal Python Example Source: https://github.com/agnesai-labs/agnes-ai/blob/main/CHANGELOG.md A basic example demonstrating how to interact with the API using Python. ```python import os import openai openai.api_key = os.getenv("AGNES_API_KEY") completion = openai.ChatCompletion.create( model="agnes-2.0-flash", messages=[ {"role": "user", "content": "Hello Agnes!"} ] ) print(completion.choices[0].message.content) ``` -------------------------------- ### Minimal Curl Example Source: https://github.com/agnesai-labs/agnes-ai/blob/main/CHANGELOG.md A basic example demonstrating how to interact with the API using curl. ```bash curl -X POST \ 'https://api.agnesai.com/v1/chat/completions' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{ "model": "agnes-2.0-flash", "messages": [{"role": "user", "content": "Hello Agnes!"}] }' ``` -------------------------------- ### Minimal Node.js Example Source: https://github.com/agnesai-labs/agnes-ai/blob/main/CHANGELOG.md A basic example demonstrating how to interact with the API using Node.js. ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: process.env.AGNES_API_KEY, }); async function main() { const completion = await openai.chat.completions.create({ model: "agnes-2.0-flash", messages: [ {"role": "user", "content": "Hello Agnes!"}, ], }); console.log(completion.choices[0].message.content); } main(); ``` -------------------------------- ### Query Video Results by Video ID Source: https://github.com/agnesai-labs/agnes-ai/blob/main/docs/FAQ.md Use this GET request to retrieve video results using the returned video_id. Do not use task_id for current video result polling unless specifically documented. ```text GET https://apihub.agnes-ai.com/agnesapi?video_id= ``` -------------------------------- ### Video Generation API Request Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Initiate a video generation task using this cURL command. Video generation is asynchronous; you will receive a `video_id` to poll for results. Ensure your API key is correctly configured. ```bash curl -X POST https://apihub.agnes-ai.com/v1/videos \ -H "Authorization: Bearer $AGNES_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "agnes-video-v2.0", "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting, realistic motion", "height": 768, "width": 1152, "num_frames": 121, "frame_rate": 24 }' ``` -------------------------------- ### Video Generation Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Generate videos from text prompts. This is an asynchronous process that requires creating a task and then polling for the result. ```APIDOC ## POST /v1/videos ### Description Initiates a video generation task based on the provided prompt and parameters. Video generation is asynchronous. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/videos ### Parameters #### Request Body - **model** (string) - Required - The video generation model to use (e.g., "agnes-video-v2.0"). - **prompt** (string) - Required - A detailed description of the video to generate. - **height** (integer) - Required - The height of the generated video in pixels. - **width** (integer) - Required - The width of the generated video in pixels. - **num_frames** (integer) - Required - The total number of frames for the video. - **frame_rate** (integer) - Required - The frame rate of the generated video. ### Request Example ```json { "model": "agnes-video-v2.0", "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting, realistic motion", "height": 768, "width": 1152, "num_frames": 121, "frame_rate": 24 } ``` ### Response #### Success Response (200) - **video_id** (string) - A unique identifier for the video generation task. #### Response Example ```json { "video_id": "vid_abc123xyz789" } ``` ## GET /agnesapi?video_id= ### Description Polls for the result of a video generation task using the `video_id`. ### Method GET ### Endpoint https://apihub.agnes-ai.com/agnesapi?video_id= ### Parameters #### Query Parameters - **video_id** (string) - Required - The ID of the video generation task to query. ### Response #### Success Response (200) - **status** (string) - The status of the video generation task (e.g., "processing", "completed", "failed"). - **url** (string) - The URL of the generated video if the status is "completed". #### Response Example ```json { "status": "completed", "url": "https://apihub.agnes-ai.com/videos/generated/video1.mp4" } ``` ``` -------------------------------- ### Set AGNES_API_KEY Environment Variable Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Use this command to set your API key as an environment variable for local development. Replace 'your_api_key_here' with your actual key. ```bash export AGNES_API_KEY="your_api_key_here" ``` -------------------------------- ### Chat Completions Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Generate chat completions by sending a prompt to the chat API. Supports streaming for real-time responses. ```APIDOC ## POST /v1/chat/completions ### Description Generates a chat completion response based on the provided messages and model. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for chat completions (e.g., "agnes-2.0-flash"). - **messages** (array) - Required - An array of message objects, each with a `role` (user, system, assistant) and `content`. - **stream** (boolean) - Optional - Whether to stream the response. Defaults to false. ### Request Example ```json { "model": "agnes-2.0-flash", "messages": [ { "role": "user", "content": "Explain how to integrate an OpenAI-compatible API gateway." } ], "stream": true } ``` ### Response #### Success Response (200) - **content** (string) - The generated chat response. - **role** (string) - The role of the message sender (e.g., "assistant"). #### Response Example ```json { "model": "agnes-2.0-flash", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "To integrate an OpenAI-compatible API gateway..." }, "finish_reason": "stop" } ] } ``` ``` -------------------------------- ### Chat Completions API Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md Use the chat completions endpoint for both `agnes-1.5-flash` and `agnes-2.0-flash` models. `agnes-1.5-flash` is recommended for high-throughput, low-latency tasks, while `agnes-2.0-flash` supports advanced features like tool calling, coding, reasoning, and multimodal input. ```APIDOC ## POST /v1/chat/completions ### Description Provides chat completions and text generation capabilities. Supports image URL input for multimodal tasks with `agnes-2.0-flash`. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for chat completions (e.g., `agnes-1.5-flash`, `agnes-2.0-flash`). - **messages** (array) - Required - A list of messages comprising the conversation. - **stream** (boolean) - Optional - Whether to stream back partial message deltas as they are generated. - **tools** (array) - Optional - A list of tools the model may call. - **tool_choice** (string or object) - Optional - Controls how the tools are called. ### Request Example ```json { "model": "agnes-2.0-flash", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?", "image_url": "https://example.com/image.jpg"} ], "stream": true } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the response. - **choices** (array) - A list of generated message choices. - **usage** (object) - Usage statistics for the request. #### Response Example ```json { "id": "chatcmpl-123", "choices": [ { "message": { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020." } } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } } ``` ``` -------------------------------- ### Legacy Video Task Query Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md This is a legacy format for querying video task results using task_id. It is recommended to use video_id for current integrations. ```text GET https://apihub.agnes-ai.com/v1/videos/{task_id} ``` -------------------------------- ### OpenAI-Compatible Chat Completions Endpoint Source: https://github.com/agnesai-labs/agnes-ai/blob/main/docs/FAQ.md Agnes AI supports OpenAI-compatible integrations. Use this endpoint for chat workflows. ```text POST /v1/chat/completions ``` -------------------------------- ### Image Generation API Request Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Send a request to the Agnes AI API to generate an image. Replace "$AGNES_API_KEY" with your actual API key or ensure it's set as an environment variable. The "size" parameter specifies the output resolution. ```bash curl https://apihub.agnes-ai.com/v1/images/generations \ -H "Authorization: Bearer $AGNES_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "agnes-image-2.1-flash", "prompt": "A luminous floating city above a misty canyon at sunrise, cinematic realism", "size": "1024x768" }' ``` -------------------------------- ### Image Generations Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Create images from text prompts using the image generation API. ```APIDOC ## POST /v1/images/generations ### Description Generates an image based on the provided text prompt and model. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/images/generations ### Parameters #### Request Body - **model** (string) - Required - The image generation model to use (e.g., "agnes-image-2.1-flash"). - **prompt** (string) - Required - A detailed description of the image to generate. - **size** (string) - Optional - The desired size of the generated image (e.g., "1024x768"). ### Request Example ```json { "model": "agnes-image-2.1-flash", "prompt": "A luminous floating city above a misty canyon at sunrise, cinematic realism", "size": "1024x768" } ``` ### Response #### Success Response (200) - **url** (string) - The URL of the generated image. #### Response Example ```json { "created": 1678887000, "data": [ { "url": "https://apihub.agnes-ai.com/images/generated/image1.png" } ] } ``` ``` -------------------------------- ### Video Generation Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md Generates videos from text, images, or multiple images. Supports keyframe animation and asynchronous generation. Use the returned video_id to poll for results. ```APIDOC ## POST /v1/videos ### Description Generates videos based on text or image inputs. Supports multi-image video and keyframe animation. Generation is asynchronous. ### Method POST ### Endpoint /v1/videos ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt to guide video generation. - **image_inputs** (array) - Optional - An array of images for image-to-video or multi-image video generation. - **keyframes** (array) - Optional - Keyframe data for animation control. ### Request Example ```json { "prompt": "A robot walking through a forest", "image_inputs": ["url1", "url2"] } ``` ### Response #### Success Response (200) - **video_id** (string) - The ID to poll for video generation results. #### Response Example ```json { "video_id": "v_abc123xyz" } ``` ``` ```APIDOC ## GET /agnesapi?video_id= ### Description Polls for the results of a video generation task using the provided `video_id`. ### Method GET ### Endpoint /agnesapi ### Parameters #### Query Parameters - **video_id** (string) - Required - The ID of the video generation task. ### Response #### Success Response (200) - **status** (string) - The current status of the video generation (e.g., 'processing', 'completed', 'failed'). - **video_url** (string) - The URL of the generated video if status is 'completed'. #### Response Example ```json { "status": "completed", "video_url": "https://example.com/video.mp4" } ``` ``` ```APIDOC ## GET /v1/videos/{task_id} ### Description Legacy endpoint to query video results using a `task_id`. It is recommended to use `video_id` for current integrations. ### Method GET ### Endpoint /v1/videos/{task_id} ### Parameters #### Path Parameters - **task_id** (string) - Required - The ID of the video generation task (legacy). ### Response #### Success Response (200) - **status** (string) - The current status of the video generation. - **video_url** (string) - The URL of the generated video if available. #### Response Example ```json { "status": "completed", "video_url": "https://example.com/legacy_video.mp4" } ``` ``` -------------------------------- ### Agnes AI API Configuration Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md Configure your client or tool to use Agnes AI by setting the Base URL and API Key. The chat endpoint is also specified for compatibility. ```text Base URL: https://apihub.agnes-ai.com/v1 API Key: YOUR_API_KEY Chat endpoint: /v1/chat/completions ``` -------------------------------- ### Authentication Header Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md Include this header in your API requests for authentication. ```text Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### Retry on Upstream Processing Timeout Error (524) Source: https://github.com/agnesai-labs/agnes-ai/blob/main/docs/ERROR_CODES.md Implement exponential backoff for requests where the connection succeeds but upstream processing exceeds the allowed time. This often occurs with long-context tasks, image/video generation, or high service load. ```text 524 Timeout Occurred ``` -------------------------------- ### Chat Completion API Request Source: https://github.com/agnesai-labs/agnes-ai/blob/main/README.md Use this cURL command to send a chat completion request to the Agnes AI API. Ensure your AGNES_API_KEY is set as an environment variable. Streaming is enabled by default. ```bash curl https://apihub.agnes-ai.com/v1/chat/completions \ -H "Authorization: Bearer $AGNES_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "agnes-2.0-flash", "messages": [ { "role": "user", "content": "Explain how to integrate an OpenAI-compatible API gateway." } ], "stream": true }' ``` -------------------------------- ### Retry on Gateway Timeout Error (522) Source: https://github.com/agnesai-labs/agnes-ai/blob/main/docs/ERROR_CODES.md Use exponential backoff for transient network connection timeouts between the gateway and upstream services. This error can stem from local network issues, proxy misconfigurations, or DNS problems. ```text 522 Connection Timed Out ``` -------------------------------- ### Image Generation Source: https://github.com/agnesai-labs/agnes-ai/blob/main/MODEL_CATALOG.md Generates images based on text or image inputs. Supports URL or Base64 output, and offers different models with varying capabilities for image editing and flexible sizing. ```APIDOC ## POST /v1/images/generations ### Description Generates images based on text-to-image or image-to-image prompts. Supports URL or Base64 output. ### Method POST ### Endpoint /v1/images/generations ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt to guide image generation. - **image_input** (string) - Optional - An image input for image-to-image transformations. - **output_format** (string) - Optional - Specifies the output format, e.g., 'url' or 'base64'. ### Request Example ```json { "prompt": "A futuristic cityscape at sunset", "output_format": "url" } ``` ### Response #### Success Response (200) - **output** (string) - The generated image URL or Base64 data. #### Response Example ```json { "output": "https://example.com/image.png" } ``` ``` -------------------------------- ### Agnes AI API Base URL Source: https://github.com/agnesai-labs/agnes-ai/blob/main/docs/FAQ.md This is the base URL for all Agnes AI API requests. Ensure this is correctly configured in your application. ```text https://apihub.agnes-ai.com/v1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.