### Video Generation - Start Job (Bash) Source: https://context7.com/vibheksoni/free-ai/llms.txt Starts a deferred video generation job. This is the first step in a two-step process. The response includes a `request_id` needed for polling. ```bash # Step 1: Start the job curl https://api.freetheai.xyz/v1/videos/generations \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-video", "prompt": "A neon sports car slowly driving through rainy city lights", "duration": 5, "resolution": "480p", "aspect_ratio": "16:9" }' ``` -------------------------------- ### Basic Chat Completions Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Interact with chat models to get text completions. This example demonstrates sending a user message and receiving a response. Replace YOUR_API_KEY with your actual API key. ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wsf/kimi-k2.6", "messages": [ { "role": "user", "content": "Write a Python hello world." } ] }' ``` -------------------------------- ### Start Video Generation Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Initiate a video generation job. Specify the model, prompt, desired duration, resolution, and aspect ratio. Replace YOUR_API_KEY with your actual API key. ```bash curl https://api.freetheai.xyz/v1/videos/generations \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-video", "prompt": "A neon sports car slowly driving through rainy city lights", "duration": 5, "resolution": "480p", "aspect_ratio": "16:9" }' ``` -------------------------------- ### Generate MP3 Audio with Whisper Wrapper Source: https://context7.com/vibheksoni/free-ai/llms.txt This example shows how to generate speech in MP3 format using the 'whisper' wrapper. The 'response_format' should be set to 'mp3'. ```bash curl https://api.freetheai.xyz/v1/audio/speech \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ --output speech.mp3 \ -d '{ "model": "xai/grok-tts", "input": "Do not tell anyone", "voice": "Ara", "wrapper": "whisper", "response_format": "mp3" }' ``` -------------------------------- ### Video Generation Pending Status Example Source: https://github.com/vibheksoni/free-ai/blob/master/README.md This is an example of the JSON payload returned when a video generation job is still pending. It indicates the current status and progress percentage. ```json {"status":"pending","progress":0} ``` -------------------------------- ### JavaScript SDK Example for Chat Completions Source: https://github.com/vibheksoni/free-ai/blob/master/README.md This JavaScript code snippet demonstrates how to use the OpenAI SDK to create a chat completion. It initializes the client with an API key and base URL, then sends a user message to the 'wsf/kimi-k2.6' model. The content of the assistant's reply is logged to the console. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.freetheai.xyz/v1" }); const completion = await client.chat.completions.create({ model: "wsf/kimi-k2.6", messages: [ { role: "user", content: "Say hello in one sentence." } ] }); console.log(completion.choices[0].message.content); ``` -------------------------------- ### Image Generation Request Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Generate images using the specified AI model. This example shows how to set the model, prompt, number of images, aspect ratio, and resolution. Replace YOUR_API_KEY with your actual API key. ```bash curl https://api.freetheai.xyz/v1/images/generations \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-image", "prompt": "A neon sports car parked under rainy city lights", "n": 1, "aspect_ratio": "auto", "resolution": "1k" }' ``` -------------------------------- ### Chat Completions Source: https://context7.com/vibheksoni/free-ai/llms.txt This section details how to use the chat completions endpoint, which allows for interaction with various language models. It includes an example of using the OpenAI Python client to create a completion with tool calling capabilities. ```APIDOC ## Chat Completions This endpoint allows for chat-based interactions with AI models, including support for tool calling. ### Method POST ### Endpoint `/v1/chat/completions` ### Request Body - **model** (string) - Required - The model to use for the chat completion. - **tool_choice** (string) - Optional - Controls how the model selects a tool. Can be `required`. - **messages** (array) - Required - A list of message objects representing the conversation history. - **tools** (array) - Optional - A list of tool definitions the model can use. ### Request Example ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1" ) completion = client.chat.completions.create( model="wsf/swe-1.6", tool_choice="required", messages=[{"role": "user", "content": "Use get_weather for Boston." }], tools=[ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], "additionalProperties": False, }, }, } ], ) tool_call = completion.choices[0].message.tool_calls[0] print(tool_call.function.name) print(tool_call.function.arguments) ``` ### Response #### Success Response (200) - **choices** (array) - A list of completion choices. - **message** (object) - **tool_calls** (array) - If tool calling is used, this contains the tool calls. - **function** (object) - **name** (string) - The name of the function to call. - **arguments** (string) - JSON string of arguments for the function. ### Response Example ```json { "choices": [ { "message": { "tool_calls": [ { "function": { "name": "get_weather", "arguments": "{\"city\": \"Boston\"}" } } ] } } ] } ``` ``` -------------------------------- ### Video Generation Source: https://context7.com/vibheksoni/free-ai/llms.txt Starts a deferred video generation job and provides endpoints to poll for the status and retrieve the final video. ```APIDOC ## Video Generation Starts a deferred video generation job and returns a `request_id`. Poll the status endpoint until the final video payload is ready. Currently limited to `480p`, 1–5 seconds duration. ### Method POST (Start Job), GET (Poll Status) ### Endpoints - **Start Job:** `/v1/videos/generations` - **Poll Status:** `/v1/videos/:request_id` ### Parameters (Start Job) #### Request Body - **model** (string) - Required - The video generation model to use. - **prompt** (string) - Required - The text prompt to generate the video from. - **duration** (integer) - Required - The duration of the video in seconds (1-5). - **resolution** (string) - Required - The resolution of the video (e.g., '480p'). - **aspect_ratio** (string) - Required - The aspect ratio of the video (e.g., '16:9'). ### Request Example (Start Job) ```bash # Step 1: Start the job curl https://api.freetheai.xyz/v1/videos/generations \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-video", "prompt": "A neon sports car slowly driving through rainy city lights", "duration": 5, "resolution": "480p", "aspect_ratio": "16:9" }' ``` ### Response (Start Job) #### Success Response (200) - **request_id** (string) - The ID for the video generation request. - **status** (string) - The initial status of the job (e.g., 'pending'). ### Response Example (Start Job) ```json { "request_id": "abc123", "status": "pending" } ``` ### Request Example (Poll Status) ```bash # Step 2: Poll until complete curl https://api.freetheai.xyz/v1/videos/abc123 \ -H "Authorization: Bearer $FREETHEAI_API_KEY" ``` ### Response (Poll Status) #### Pending Response - **status** (string) - The current status ('pending'). - **progress** (integer) - The progress of the generation (0-100). #### Complete Response - **status** (string) - The final status ('complete'). - **video_url** (string) - The URL of the generated video. ### Response Example (Pending) ```json { "status": "pending", "progress": 0 } ``` ### Response Example (Complete) ```json { "status": "complete", "video_url": "https://..." } ``` ### Python Client Example ```python import time, requests API_KEY = "YOUR_API_KEY" BASE = "https://api.freetheai.xyz/v1" HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} # Start job resp = requests.post(f"{BASE}/videos/generations", headers=HEADERS, json={ "model": "xai/grok-imagine-video", "prompt": "Ocean waves crashing at sunset", "duration": 3, "resolution": "480p", "aspect_ratio": "16:9" }) request_id = resp.json()["request_id"] # Poll while True: status_resp = requests.get(f"{BASE}/videos/{request_id}", headers=HEADERS) data = status_resp.json() if data["status"] == "complete": print("Video URL:", data["video_url"]) break print(f"Progress: {data.get('progress', 0)}%") time.sleep(5) ``` ``` -------------------------------- ### Non-streaming Tool Call Example with cURL Source: https://github.com/vibheksoni/free-ai/blob/master/README.md This cURL command demonstrates a non-streaming tool call for chat completions. It specifies a model, tool choice, messages, and defines a 'get_weather' tool with city parameter. The expected result indicates 'tool_calls' and a populated 'message.tool_calls'. ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wsf/swe-1.6", "tool_choice": "required", "messages": [ { "role": "user", "content": "Use the get_weather tool for Boston and do not answer directly." } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"], "additionalProperties": false } } } ] }' ``` -------------------------------- ### Video Generation - Poll Status (Bash) Source: https://context7.com/vibheksoni/free-ai/llms.txt Polls the status of a deferred video generation job using the `request_id` obtained from the start job step. Continue polling until the status is 'complete'. ```bash # Step 2: Poll until complete curl https://api.freetheai.xyz/v1/videos/abc123 \ -H "Authorization: Bearer $FREETHEAI_API_KEY" ``` -------------------------------- ### Messages API Request (Bash) Source: https://context7.com/vibheksoni/free-ai/llms.txt Example of making a request to the Anthropic-style messages API using curl. This endpoint is suitable for agent frameworks expecting the Anthropic SDK shape. The response follows the Anthropic messages shape. ```bash curl https://api.freetheai.xyz/v1/messages \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "rev/claude-sonnet-4.5", "max_tokens": 256, "messages": [ { "role": "user", "content": "Reply with a compact migration plan." } ] }' ``` -------------------------------- ### Chat Completion with Tool Use (Python) Source: https://context7.com/vibheksoni/free-ai/llms.txt Demonstrates how to use the OpenAI client to create chat completions that utilize a tool. Ensure your API key and base URL are correctly configured. The tool_choice parameter is set to 'required' to enforce tool usage. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1" ) completion = client.chat.completions.create( model="wsf/swe-1.6", tool_choice="required", messages=[{"role": "user", "content": "Use get_weather for Boston."} ], tools=[ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], "additionalProperties": False, }, }, } ], ) tool_call = completion.choices[0].message.tool_calls[0] print(tool_call.function.name) # get_weather print(tool_call.function.arguments) # {"city":"Boston"} ``` -------------------------------- ### List Available Models Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Use this command to retrieve a catalog of available AI models from the API. Ensure you replace YOUR_API_KEY with your actual API key. ```bash curl https://api.freetheai.xyz/v1/models \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### List Available AI Models Source: https://context7.com/vibheksoni/free-ai/llms.txt Retrieves the lightweight, live model catalog. Use the exact alias IDs from this response in subsequent API requests. ```bash curl https://api.freetheai.xyz/v1/models \ -H "Authorization: Bearer $FREETHEAI_API_KEY" # Example response (truncated): # { # "object": "list", # "data": [ # { "id": "glm/glm-5.1", "object": "model" }, # { "id": "wsf/kimi-k2.6", "object": "model" }, # { "id": "bbl/gpt-5", "object": "model" }, # ... # ] # } ``` -------------------------------- ### Tool Calling with Python SDK Source: https://github.com/vibheksoni/free-ai/blob/master/README.md This Python script shows how to perform tool calling using the OpenAI SDK. It initializes the client with API key and base URL, then creates a chat completion request specifying the model, tool choice, messages, and the 'get_weather' tool definition. The tool calls are printed to the console. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1", ) completion = client.chat.completions.create( model="wsf/swe-1.6", tool_choice="required", messages=[ { "role": "user", "content": "Use the get_weather tool for Boston and do not answer directly." } ], tools=[ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": { "city": {"type": "string"} }, "required": ["city"], "additionalProperties": False, }, }, } ], ) print(completion.choices[0].message.tool_calls) ``` -------------------------------- ### Video Generation with Python Source: https://context7.com/vibheksoni/free-ai/llms.txt Initiates a video generation job and then polls for its completion using the `requests` library. The script prints the video URL once the job is complete. Adjust the sleep interval as needed. ```python import time, requests API_KEY = "YOUR_API_KEY" BASE = "https://api.freetheai.xyz/v1" HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} # Start job resp = requests.post(f"{BASE}/videos/generations", headers=HEADERS, json={ "model": "xai/grok-imagine-video", "prompt": "Ocean waves crashing at sunset", "duration": 3, "resolution": "480p", "aspect_ratio": "16:9" }) request_id = resp.json()["request_id"] # Poll while True: status_resp = requests.get(f"{BASE}/videos/{request_id}", headers=HEADERS) data = status_resp.json() if data["status"] == "complete": print("Video URL:", data["video_url"]) break print(f"Progress: {data.get('progress', 0)}%") time.sleep(5) ``` -------------------------------- ### Chat Completions with Python SDK Source: https://context7.com/vibheksoni/free-ai/llms.txt Demonstrates non-streaming and streaming chat completions using the OpenAI Python SDK. Ensure your `base_url` is set to the FreeTheAi endpoint. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1" ) # Non-streaming response = client.chat.completions.create( model="wsf/kimi-k2.6", messages=[ {"role": "user", "content": "Write a Python hello world."} ] ) print(response.choices[0].message.content) # Streaming stream = client.chat.completions.create( model="glm/glm-5.1", messages=[{"role": "user", "content": "Ship a tiny REST API example."} ], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True) ``` -------------------------------- ### Chat Completions with JavaScript SDK Source: https://context7.com/vibheksoni/free-ai/llms.txt Shows how to perform chat completions using the OpenAI JavaScript SDK. Set the `baseURL` to `https://api.freetheai.xyz/v1` and provide your API key. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.FREETHEAI_API_KEY, baseURL: "https://api.freetheai.xyz/v1" }); const completion = await client.chat.completions.create({ model: "wsf/kimi-k2.6", messages: [{ role: "user", content: "Say hello in one sentence." }] }); console.log(completion.choices[0].message.content); ``` -------------------------------- ### Tool Calling with Chat Completions Source: https://context7.com/vibheksoni/free-ai/llms.txt Utilizes the chat completions endpoint to enable tool calling. Send standard OpenAI function schemas and specify `tool_choice` to receive structured `tool_calls` in the response. ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wsf/swe-1.6", "tool_choice": "required", "messages": [ { "role": "user", "content": "Use the get_weather tool for Boston and do not answer directly." } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"], "additionalProperties": false } } } ] }' # Expected response shape: # choices[0].finish_reason == "tool_calls" # choices[0].message.tool_calls[0].function.name == "get_weather" ``` -------------------------------- ### Fetch Live Access Policy Source: https://context7.com/vibheksoni/free-ai/llms.txt Retrieve the current access policy, including rate limits and tier thresholds, by calling this endpoint. ```bash curl https://api.freetheai.xyz/access-policy.json ``` -------------------------------- ### Image Generation Request (Bash) Source: https://context7.com/vibheksoni/free-ai/llms.txt Initiates an image generation request using the `xai/grok-imagine-image` model. The response contains a base64-encoded PNG image. Ensure the API key and content type are set correctly. ```bash curl https://api.freetheai.xyz/v1/images/generations \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-imagine-image", "prompt": "A neon sports car parked under rainy city lights", "n": 1, "aspect_ratio": "auto", "resolution": "1k" }' ``` -------------------------------- ### List Models Source: https://context7.com/vibheksoni/free-ai/llms.txt Returns the lightweight live model catalog used by API clients. The response is an OpenAI-compatible model list with all currently available alias IDs. Use exact alias IDs from this response in all subsequent requests. ```APIDOC ## List Models — `GET /v1/models` Returns the lightweight live model catalog used by API clients. The response is an OpenAI-compatible model list with all currently available alias IDs. Use exact alias IDs from this response in all subsequent requests. ```bash curl https://api.freetheai.xyz/v1/models \ -H "Authorization: Bearer $FREETHEAI_API_KEY" # Example response (truncated): # { # "object": "list", # "data": [ # { "id": "glm/glm-5.1", "object": "model" }, # { "id": "wsf/kimi-k2.6", "object": "model" }, # { "id": "bbl/gpt-5", "object": "model" }, # ... # ] # } ``` ``` -------------------------------- ### List Models Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Retrieves a lightweight catalog of available models for API clients. ```APIDOC ## GET /v1/models ### Description Lightweight live model catalog for API clients ### Method GET ### Endpoint /v1/models ### Request Example ```bash curl https://api.freetheai.xyz/v1/models \ -H "Authorization: Bearer YOUR_API_KEY" ``` ``` -------------------------------- ### Image Generation with Python Client Source: https://context7.com/vibheksoni/free-ai/llms.txt Generates an image using the OpenAI Python client and saves it to a file. The response is decoded from base64 and written to 'output.png'. Requires the `openai` library and correct API key/base URL. ```python import base64, open as _open from openai import OpenAI client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1") response = client.images.generate( model="xai/grok-imagine-image", prompt="A neon sports car parked under rainy city lights", n=1, extra_body={"aspect_ratio": "auto", "resolution": "1k"} ) img_bytes = base64.b64decode(response.data[0].b64_json) with open("output.png", "wb") as f: f.write(img_bytes) ``` -------------------------------- ### Chat Completions with Streaming Source: https://context7.com/vibheksoni/free-ai/llms.txt An OpenAI-compatible endpoint for chat completions that supports streaming responses. Change the `baseURL` to use this service. ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "glm/glm-5.1", "stream": true, "messages": [ { "role": "system", "content": "You are a concise technical assistant." }, { "role": "user", "content": "Build me a clean product launch checklist." } ] }' ``` -------------------------------- ### Chat Completions Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Provides OpenAI-compatible chat completions. ```APIDOC ## POST /v1/chat/completions ### Description OpenAI-compatible chat completions ### Method POST ### Endpoint /v1/chat/completions ### Request Body - **model** (string) - Required - The model to use for chat completions. - **messages** (array) - Required - An array of message objects, each with a `role` and `content`. ### Request Example ```json { "model": "wsf/kimi-k2.6", "messages": [ { "role": "user", "content": "Write a Python hello world." } ] } ``` ### Response #### Success Response (200) - **choices** (array) - Description of the model's response choices. - **created** (integer) - Timestamp of when the response was created. - **id** (string) - Unique identifier for the response. - **model** (string) - The model used for the response. - **object** (string) - The type of object returned (e.g., `chat.completion`). - **usage** (object) - Information about token usage. ``` -------------------------------- ### Chat Completions Source: https://context7.com/vibheksoni/free-ai/llms.txt OpenAI-compatible chat completions endpoint supporting streaming, multi-turn conversations, and tool calling. Drop-in replacement for the OpenAI API — just change `baseURL`. ```APIDOC ## Chat Completions — `POST /v1/chat/completions` OpenAI-compatible chat completions endpoint supporting streaming, multi-turn conversations, and tool calling. Drop-in replacement for the OpenAI API — just change `baseURL`. ```bash # Streaming curl example curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "glm/glm-5.1", "stream": true, "messages": [ { "role": "system", "content": "You are a concise technical assistant." }, { "role": "user", "content": "Build me a clean product launch checklist." } ] }' ``` ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1" ) # Non-streaming response = client.chat.completions.create( model="wsf/kimi-k2.6", messages=[ {"role": "user", "content": "Write a Python hello world."} ] ) print(response.choices[0].message.content) # Streaming stream = client.chat.completions.create( model="glm/glm-5.1", messages=[{"role": "user", "content": "Ship a tiny REST API example."}], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True) ``` ```js import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.FREETHEAI_API_KEY, baseURL: "https://api.freetheai.xyz/v1" }); const completion = await client.chat.completions.create({ model: "wsf/kimi-k2.6", messages: [{ role: "user", content: "Say hello in one sentence." }] }); console.log(completion.choices[0].message.content); ``` ``` -------------------------------- ### Video Generation Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Initiates video generation based on a prompt and polls for status. ```APIDOC ## POST /v1/videos/generations ### Description Start video generation ### Method POST ### Endpoint /v1/videos/generations ### Parameters #### Request Body - **model** (string) - Required - The video generation model to use. - **prompt** (string) - Required - The text prompt for video generation. - **duration** (integer) - Optional - The desired duration of the video in seconds. - **resolution** (string) - Optional - The resolution of the video (e.g., "480p", "1080p"). - **aspect_ratio** (string) - Optional - The aspect ratio of the video (e.g., "16:9"). ### Request Example ```json { "model": "xai/grok-imagine-video", "prompt": "A neon sports car slowly driving through rainy city lights", "duration": 5, "resolution": "480p", "aspect_ratio": "16:9" } ``` ## GET /v1/videos/:request_id ### Description Poll video generation status ### Method GET ### Endpoint /v1/videos/:request_id ### Response #### Pending Response (202) - **status** (string) - Indicates the job is pending. - **progress** (integer) - The current progress of the video generation. #### Success Response (200) - Contains the final video payload once generation is complete. ``` -------------------------------- ### Generate PCM Audio Output Source: https://context7.com/vibheksoni/free-ai/llms.txt Use this endpoint to generate speech in PCM format. Ensure the 'response_format' is set to 'pcm'. ```bash curl https://api.freetheai.xyz/v1/audio/speech \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ --output speech.pcm \ -d '{ "model": "xai/grok-tts", "input": "Hello, how are you?", "voice": "Eve", "wrapper": "soft", "response_format": "pcm", "language": "en" }' ``` -------------------------------- ### Chat Completions with Tool Calling Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Enables chat completions with the ability to call external tools based on the user's request. ```APIDOC ## POST /v1/chat/completions ### Description Provides chat completions and supports tool calling, allowing the model to invoke specified functions. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model to use for chat completions (e.g., `wsf/swe-1.6`). - **tool_choice** (string) - Optional - Determines how the model should use tools. `required` means the model must use a tool. - **messages** (array) - Required - A list of message objects representing the conversation history. - **role** (string) - Required - The role of the message sender (`user`, `assistant`, `system`). - **content** (string) - Required - The content of the message. - **tools** (array) - Optional - A list of tools the model can use. - **type** (string) - Required - The type of tool (e.g., `function`). - **function** (object) - Required - Describes the function tool. - **name** (string) - Required - The name of the function. - **description** (string) - Optional - A description of what the function does. - **parameters** (object) - Required - The parameters the function accepts. - **type** (string) - Required - The type of the parameters object (e.g., `object`). - **properties** (object) - Required - An object defining the properties of the parameters. - **param_name** (object) - Required - Defines a specific parameter. - **type** (string) - Required - The data type of the parameter (e.g., `string`, `integer`). - **required** (array) - Optional - A list of parameter names that are required. - **additionalProperties** (boolean) - Optional - Whether additional properties are allowed. ### Request Example (Non-streaming) ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "model": "wsf/swe-1.6", \ "tool_choice": "required", \ "messages": [ \ { \ "role": "user", \ "content": "Use the get_weather tool for Boston and do not answer directly." \ } \ ], \ "tools": [ \ { \ "type": "function", \ "function": { \ "name": "get_weather", \ "description": "Get the weather for a city.", \ "parameters": { \ "type": "object", \ "properties": { \ "city": { "type": "string" } \ }, \ "required": ["city"], \ "additionalProperties": false \ } \ } \ } \ ] \ }' ``` ### Response #### Success Response (200) - **choices** (array) - Contains the completion choices. - **finish_reason** (string) - Indicates why the model stopped generating tokens (e.g., `tool_calls`). - **message** (object) - The message object. - **tool_calls** (array) - Present if `finish_reason` is `tool_calls`, containing information about the tool calls. ### Python SDK Example ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.freetheai.xyz/v1", ) completion = client.chat.completions.create( model="wsf/swe-1.6", tool_choice="required", messages=[ { "role": "user", "content": "Use the get_weather tool for Boston and do not answer directly." } ], tools=[ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": { "city": {"type": "string"} }, "required": ["city"], "additionalProperties": False, }, }, } ], ) print(completion.choices[0].message.tool_calls) ``` ### JavaScript SDK Example ```js import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.freetheai.xyz/v1" }); const completion = await client.chat.completions.create({ model: "wsf/kimi-k2.6", messages: [ { role: "user", content: "Say hello in one sentence." } ] }); console.log(completion.choices[0].message.content); ``` ``` -------------------------------- ### Generate Speech using cURL Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Use this cURL command to generate speech from text. Specify the model, input text, voice, wrapper, response format (pcm or mp3), and language. The output is saved to speech.pcm. ```bash curl https://api.freetheai.xyz/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ --output speech.pcm \ -d '{ "model": "xai/grok-tts", "input": "Hello, how are you?", "voice": "Eve", "wrapper": "soft", "response_format": "pcm", "language": "en" }' ``` -------------------------------- ### Tool Calling Source: https://context7.com/vibheksoni/free-ai/llms.txt Send standard OpenAI function/tool schemas. Supported model aliases return structured `tool_calls` in the response when `tool_choice: "required"` or `"auto"` is set. ```APIDOC ## Tool Calling — `POST /v1/chat/completions` with `tools` Send standard OpenAI function/tool schemas. Supported model aliases return structured `tool_calls` in the response when `tool_choice: "required"` or `"auto"` is set. ```bash curl https://api.freetheai.xyz/v1/chat/completions \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wsf/swe-1.6", "tool_choice": "required", "messages": [ { "role": "user", "content": "Use the get_weather tool for Boston and do not answer directly." } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a city.", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"], "additionalProperties": false } } } ] }' # Expected response shape: # choices[0].finish_reason == "tool_calls" # choices[0].message.tool_calls[0].function.name == "get_weather" ``` ``` -------------------------------- ### Poll Video Generation Status Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Check the status of a video generation job using its request ID. You will receive a 'pending' status with progress until the video is ready. Replace YOUR_API_KEY and REQUEST_ID with your actual API key and the job's request ID. ```bash curl https://api.freetheai.xyz/v1/videos/REQUEST_ID \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Speech Synthesis (MP3 Output) Source: https://context7.com/vibheksoni/free-ai/llms.txt Generates speech audio in MP3 format using a specified model, voice, and input text. The output is saved to a file. ```APIDOC ## POST /v1/audio/speech (MP3 Output) ### Description Generates speech audio in MP3 format. This endpoint allows you to convert text into speech using various AI models and voices, with a whisper wrapper option, saving the output directly to a file. ### Method POST ### Endpoint https://api.freetheai.xyz/v1/audio/speech ### Parameters #### Request Body - **model** (string) - Required - The AI model to use for speech synthesis (e.g., "xai/grok-tts"). - **input** (string) - Required - The text to convert into speech. - **voice** (string) - Required - The desired voice for the speech output (e.g., "Ara"). - **wrapper** (string) - Required - Specifies a wrapper for the audio output, must be "whisper". - **response_format** (string) - Required - The desired format for the audio response, must be "mp3". ### Request Example ```json { "model": "xai/grok-tts", "input": "Do not tell anyone", "voice": "Ara", "wrapper": "whisper", "response_format": "mp3" } ``` ### Response #### Success Response (200) - The audio data is saved directly to the specified output file (`speech.mp3`). No JSON response body is returned for successful audio file generation. ``` -------------------------------- ### Text-to-Speech JSON Configuration Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Configure text-to-speech requests using this JSON structure. It includes model, input, voice, wrapper, and response format. Supported wrappers like 'whisper' can modify speech characteristics. ```json { "model": "xai/grok-tts", "input": "Do not tell anyone", "voice": "Ara", "wrapper": "whisper", "response_format": "mp3" } ``` -------------------------------- ### Image Generations Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Generates images based on a provided prompt. ```APIDOC ## POST /v1/images/generations ### Description Image generation ### Method POST ### Endpoint /v1/images/generations ### Parameters #### Request Body - **model** (string) - Required - The image generation model to use. - **prompt** (string) - Required - The text prompt to generate the image from. - **n** (integer) - Optional - The number of images to generate. Defaults to 1. - **aspect_ratio** (string) - Optional - The aspect ratio of the generated image (e.g., "auto", "16:9"). - **resolution** (string) - Optional - The resolution of the generated image (e.g., "1k", "4k"). ### Request Example ```json { "model": "xai/grok-imagine-image", "prompt": "A neon sports car parked under rainy city lights", "n": 1, "aspect_ratio": "auto", "resolution": "1k" } ``` ### Response #### Success Response (200) - **data** (array) - An array of generated image objects, each containing a URL. ``` -------------------------------- ### Text-to-Speech Source: https://context7.com/vibheksoni/free-ai/llms.txt Converts text into spoken audio using the specified model and voice options. ```APIDOC ## Text-to-Speech Converts text to audio using `xai/grok-tts`. Supports `pcm` (24 kHz) and `mp3` output formats. Voices: `Ara`, `Eve`, `Leo`, `Rex`, `Sal`. Voice wrappers: `soft`, `whisper`, `loud`, `build-intensity`, `decrease-intensity`, `higher-pitch`, `lower-pitch`, `slow`, `fast`, `sing-song`, `singing`, `laugh-speak`, `emphasis`. ### Method POST ### Endpoint `/v1/audio/speech` ### Parameters #### Request Body - **model** (string) - Required - The text-to-speech model to use. - **input** (string) - Required - The text to convert to speech. - **voice** (string) - Required - The voice to use for the speech (e.g., 'Ara', 'Eve'). - **output_format** (string) - Optional - The format of the output audio ('pcm' or 'mp3', default: 'mp3'). - **voice_wrapper** (string) - Optional - A wrapper to apply to the voice (e.g., 'soft', 'loud'). ### Request Example ```bash curl https://api.freetheai.xyz/v1/audio/speech \ -H "Authorization: Bearer $FREETHEAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "xai/grok-tts", "input": "Hello, world!", "voice": "Ara", "output_format": "mp3" }' ``` ### Response #### Success Response (200) - **audio_content** (binary) - The generated audio content in the specified format. ``` -------------------------------- ### Text To Speech Source: https://github.com/vibheksoni/free-ai/blob/master/README.md Generates audio from text. Supports PCM and MP3 output formats, with various voice and wrapper options. ```APIDOC ## POST /v1/audio/speech ### Description Generates audio from text input. Supports `pcm` for 24 kHz PCM or `mp3` for MP3 output. ### Method POST ### Endpoint /v1/audio/speech ### Parameters #### Request Body - **model** (string) - Required - The model to use for speech synthesis (e.g., `xai/grok-tts`). - **input** (string) - Required - The text to convert to speech. - **voice** (string) - Required - The voice to use for speech synthesis. Supported voices: `Ara`, `Eve`, `Leo`, `Rex`, `Sal`. - **wrapper** (string) - Optional - A voice wrapper to modify the speech style. Supported wrappers: `soft`, `whisper`, `loud`, `build-intensity`, `decrease-intensity`, `higher-pitch`, `lower-pitch`, `slow`, `fast`, `sing-song`, `singing`, `laugh-speak`, `emphasis`. - **response_format** (string) - Optional - The format of the audio response. Supported values: `pcm`, `mp3`. - **language** (string) - Optional - The language of the input text (e.g., `en`). ### Request Example ```json { "model": "xai/grok-tts", "input": "Hello, how are you?", "voice": "Eve", "wrapper": "soft", "response_format": "pcm", "language": "en" } ``` ### Response #### Success Response (200) - Binary audio data (PCM or MP3 based on `response_format`). ```