### Install dependencies and set API key Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Install the example dependencies and set the AGNES_API_KEY environment variable before running the examples. ```bash pip install -r requirements.txt export AGNES_API_KEY="your_api_key_here" ``` -------------------------------- ### GET /agnesapi?video_id= Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Queries the result of a video generation task using the video_id returned from the creation request. Use this endpoint for polling the video result. ```APIDOC ## [GET] /agnesapi?video_id= ### Description Queries the result of a video generation task using the video_id returned from the creation request. Use this endpoint for polling the video result. ### Method GET ### Endpoint https://apihub.agnes-ai.com/agnesapi?video_id= ### Parameters #### Query Parameters - **video_id** (string) - Required - The identifier of the video generation task. ### Response #### Success Response (200) - **video** (object) - The generated video data. ### Request Example ```text GET https://apihub.agnes-ai.com/agnesapi?video_id= ``` ``` -------------------------------- ### GET /v1/videos/{task_id} Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Legacy endpoint for querying video results using a `task_id`. Only use this if a legacy integration specifically documents that workflow. ```APIDOC ## [GET] /v1/videos/{task_id} ### Description Legacy endpoint for querying video results using a `task_id`. Only use this if a legacy integration specifically documents that workflow. ### Method GET ### Endpoint /v1/videos/{task_id} ### Parameters #### Path Parameters - **task_id** (string) - Required - The legacy task identifier. ### Response #### Success Response (200) - **task_id** (string) - The identifier used for polling. ``` -------------------------------- ### 405 Method Not Allowed Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the endpoint does not support the HTTP method used. Common causes include using GET where POST is required, using POST where GET is required, or a third-party tool configured with the wrong method. ```APIDOC ## 405 Method Not Allowed ### Description The endpoint does not support the HTTP method. ### Status Code 405 ### Recommended Fixes - Check the endpoint documentation. - Update the client or third-party tool to use the required method. ``` -------------------------------- ### GET /agnesapi?video_id= Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Queries the result of a video generation task using the `video_id` returned from the creation endpoint. This is the current recommended polling method. ```APIDOC ## [GET] /agnesapi?video_id= ### Description Queries the result of a video generation task using the `video_id` returned from the creation endpoint. This is the current recommended polling method. ### Method GET ### Endpoint /agnesapi?video_id= ### Parameters #### Query Parameters - **video_id** (string) - Required - The video task identifier returned from the creation request. ### Response #### Success Response (200) - **video_id** (string) - The identifier used for polling. ``` -------------------------------- ### Create a video generation task with agnes-video-v2.0 Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Use this curl command to create an asynchronous video generation task. The response returns a video_id that you must use to poll for the result. Requires an AGNES_API_KEY environment variable. ```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 }' ``` -------------------------------- ### POST /v1/videos Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Creates a video generation task asynchronously. Returns a video_id that can be used to poll for the result. ```APIDOC ## [POST] /v1/videos ### Description Creates a video generation task asynchronously. Returns a video_id that can be used to poll for the result. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/videos ### Parameters #### Request Body - **model** (string) - Required - The model to use for video generation. - **prompt** (string) - Required - The text prompt describing the video. - **height** (integer) - Optional - The height of the video in pixels. - **width** (integer) - Optional - The width of the video in pixels. - **num_frames** (integer) - Optional - The number of frames to generate. - **frame_rate** (integer) - Optional - The frame rate of the video. ### Response #### Success Response (200) - **video_id** (string) - The identifier for the video generation task. ### Request Example ```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 }' ``` -------------------------------- ### Streaming chat completion with agnes-2.5-flash Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Uses the OpenAI Python client to stream a chat completion from the agnes-2.5-flash model. Requires a valid API key and the base URL https://apihub.agnes-ai.com/v1. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_AGNES_API_KEY", base_url="https://apihub.agnes-ai.com/v1", ) response = client.chat.completions.create( model="agnes-2.5-flash", messages=[ {"role": "user", "content": "Write a short intro to Agnes AI."} ], stream=True, ) for chunk in response: delta = chunk.choices[0].delta.content if delta: print(delta, end="") ``` -------------------------------- ### Generate an image with agnes-image-2.1-flash Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Use this curl command to generate an image via the Agnes AI Images API. Requires an AGNES_API_KEY environment variable. The response returns an image URL or base64 data depending on the API. ```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" }' ``` -------------------------------- ### Set AGNES_API_KEY environment variable Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Use this command to export your AgnesAI API key as an environment variable for local development. Never commit API keys, tokens, .env files, screenshots containing secrets, or private data. ```bash export AGNES_API_KEY="your_api_key_here" ``` -------------------------------- ### POST /v1/images/generations Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Generates an image based on a text prompt using the specified model. Requires an API key for authentication. ```APIDOC ## [POST] /v1/images/generations ### Description Generates an image based on a text prompt using the specified model. ### Method POST ### Endpoint https://apihub.agnes-ai.com/v1/images/generations ### Parameters #### Request Body - **model** (string) - Required - The model to use for image generation. - **prompt** (string) - Required - The text prompt describing the image. - **size** (string) - Optional - The dimensions of the generated image. ### Response #### Success Response (200) - **image** (object) - The generated image data. ### Request Example ```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" }' ``` ``` -------------------------------- ### Chat Completion Request with agnes-2.0-flash Source: https://github.com/agnesai-labs/agnesai-models/blob/main/README.md Sends a streaming chat completion request to the Agnes AI API using the agnes-2.0-flash model. Requires an API key set as the AGNES_API_KEY environment variable. The response is streamed because the stream parameter is set to true. ```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 }' ``` -------------------------------- ### POST /v1/videos Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Creates a video generation task. Supports text-to-video, image-to-video, multi-image video, and keyframe animation. Returns a `video_id` for polling the result. ```APIDOC ## [POST] /v1/videos ### Description Creates a video generation task. Supports text-to-video, image-to-video, multi-image video, and keyframe animation. Returns a `video_id` for polling the result. ### Method POST ### Endpoint /v1/videos ### Parameters #### Request Body - **model** (string) - Required - The video model to use (e.g., `agnes-video-v2.0`). ### Response #### Success Response (200) - **video_id** (string) - The identifier to use for polling the video result. ``` -------------------------------- ### POST /v1/chat/completions Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Creates a chat completion for text and agent models. Supports text generation, image URL input, streaming, tool calling, and reasoning depending on the model. ```APIDOC ## [POST] /v1/chat/completions ### Description Creates a chat completion for text and agent models. Supports text generation, image URL input, streaming, tool calling, and reasoning depending on the model. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None documented ### Response #### Success Response (200) None documented ### Request Example None documented #### Response Example None documented ``` -------------------------------- ### API Base URL Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/FAQ.md Use this base URL for all Agnes AI API requests. ```text https://apihub.agnes-ai.com/v1 ``` -------------------------------- ### Query Video Results Endpoint Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/FAQ.md Use the returned video_id to poll video results. Do not use task_id for current video result polling unless a legacy integration documents that workflow. ```text GET https://apihub.agnes-ai.com/agnesapi?video_id= ``` -------------------------------- ### Chat Completions Endpoint Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/FAQ.md Endpoint for OpenAI-compatible chat workflows. ```text POST /v1/chat/completions ``` -------------------------------- ### Legacy Task Query with task_id Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Legacy format for querying video results using task_id. Only use this for legacy integrations that specifically document this workflow; otherwise use the video_id endpoint. ```text GET https://apihub.agnes-ai.com/v1/videos/{task_id} ``` -------------------------------- ### POST /v1/images/generations Source: https://github.com/agnesai-labs/agnesai-models/blob/main/MODEL_CATALOG.md Generates images using the specified image model. Supports text-to-image, image-to-image, and output as URL or Base64. ```APIDOC ## [POST] /v1/images/generations ### Description Generates images using the specified image model. Supports text-to-image, image-to-image, and output as URL or Base64. ### Method POST ### Endpoint /v1/images/generations ### Parameters #### Request Body - **model** (string) - Required - The image model to use (e.g., `agnes-image-2.0-flash` or `agnes-image-2.1-flash`). ### Response #### Success Response (200) - **output** (array) - The generated image(s), either as URLs or Base64-encoded data. ``` -------------------------------- ### POST /v1/images/generations Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/TROUBLESHOOTING.md Endpoint for image generation and editing. Use this endpoint to create or modify images. ```APIDOC ## [POST] /v1/images/generations ### Description Endpoint for image generation and editing. ### Method POST ### Endpoint /v1/images/generations ### Response #### Success Response (200) - No response schema provided in source. ``` -------------------------------- ### 404 Not Found Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the endpoint, path, model, or resource was not found. Common causes include wrong API address, wrong Base URL, wrong endpoint path, duplicated `/v1`, invalid model name, or missing task/resource. ```APIDOC ## 404 Not Found ### Description Endpoint, path, model, or resource was not found. ### Status Code 404 ### Recommended Fixes - Confirm Base URL, endpoint path, model name, and resource ID. - Make sure tools do not append `/v1` twice. ``` -------------------------------- ### 403 Forbidden Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the account or API key does not have access. Common causes include model access not enabled, enterprise verification or subscription not taking effect, source network blocked by policy, or IP/region/network restrictions. ```APIDOC ## 403 Forbidden ### Description Account or API key does not have access. ### Status Code 403 ### Recommended Fixes - Confirm account and model permissions. - Ensure the key belongs to the correct account. - Retry from another network. - Contact support if access should be enabled. ``` -------------------------------- ### 400 Bad Request Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates invalid request parameters. Common causes include malformed JSON, missing required fields, wrong parameter types, context exceeding model limits, unsupported third-party tool payload shape, and invalid image or video parameters. ```APIDOC ## 400 Bad Request ### Description Invalid request parameters. The server cannot process the request due to malformed JSON, missing required fields, wrong parameter types, context exceeding model limits, unsupported third-party tool payload shape, or invalid image/video parameters. ### Status Code 400 ### Recommended Fixes - Validate JSON and required fields. - Reduce context; start a fresh conversation for long sessions. - Check model-specific parameters such as size, frame rate, duration, and response format placement. ``` -------------------------------- ### 409 Conflict Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the request conflicts with the current resource or task state. Common causes include duplicate task submission, same request already in progress, resource state not allowing the operation, or a tool repeatedly submitting requests. ```APIDOC ## 409 Conflict ### Description Request conflicts with the current resource or task state. ### Status Code 409 ### Recommended Fixes - Avoid duplicate submissions. - Wait for the current task to finish. - Check task status. - Add client-side duplicate-submit protection. ``` -------------------------------- ### 401 Unauthorized Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates authentication failure. Common causes include invalid, expired, missing, or incorrectly configured API key, missing Authorization header, or API key belonging to the wrong account. ```APIDOC ## 401 Unauthorized ### Description Authentication failed. The request did not pass identity verification. ### Status Code 401 ### Recommended Fixes - Use `Authorization: Bearer YOUR_API_KEY`. - Check for copied spaces or newlines. - Confirm the key is active; regenerate if needed. ``` -------------------------------- ### 402 Payment Required Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates insufficient balance or quota. Common causes include insufficient balance, insufficient Token Plan quota, request cost exceeding available quota, or subscription/recharge not yet taking effect. ```APIDOC ## 402 Payment Required ### Description Balance or quota is insufficient. ### Status Code 402 ### Recommended Fixes - Check balance, Token Plan, and subscription status. - Recharge or upgrade. - Reduce request cost by shortening context or lowering image/video specs. ``` -------------------------------- ### 408 Request Timeout Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the request timed out before completion. Common causes include unstable local network, oversized payload, long context, image/video/long-text tasks, or client timeout too short. ```APIDOC ## 408 Request Timeout ### Description Request timed out before completion. ### Status Code 408 ### Recommended Fixes - Retry and check network. - Reduce input size or lower generation specs. - Increase client timeout. - Add retry logic for long tasks. ``` -------------------------------- ### 413 Payload Too Large Source: https://github.com/agnesai-labs/agnesai-models/blob/main/docs/ERROR_CODES.md Indicates the request body is too large. Common causes include too much context, oversized Base64 image, upload exceeding limits, or too much content sent at once. ```APIDOC ## 413 Payload Too Large ### Description Request body is too large. ### Status Code 413 ### Recommended Fixes - Compress payload. - Reduce context. - Split requests. - Lower upload size or resolution. - Prefer public image URLs over large Base64 payloads when possible. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.