Skip to content

Documentation

Everything you need to integrate AI-Gate into your application. The API is OpenAI-compatible — swap the base URL and start using it immediately.

Authentication

All requests require an API key passed in the Authorization header as a Bearer token or via the standard Anthropic x-api-key header.

curl -H "Authorization: Bearer YOUR_API_KEY" \ https://ai.kenechiifeanyi.com/v1/chat/completions # Or with Anthropic / Claude extensions: curl -H "x-api-key: YOUR_API_KEY" \ https://ai.kenechiifeanyi.com/v1/messages

You can request an API key from the landing page. Once submitted, an admin reviews the request and provisions the key. You will receive an email when the key is ready.

Chat Completions

The chat completions endpoint provides an OpenAI-compatible interface for sending messages and receiving AI-generated responses.

Endpoint

POST https://ai.kenechiifeanyi.com/v1/chat/completions

Request Format

{ "messages": [ {"role": "user", "content": "Hello, how are you?"} ], "stream": true }

Response Format

Default

Streaming is the default behavior. Responses are sent as application/x-ndjson over SSE.

data: {"message": {"role": "assistant", "content": "Hello"}, "done": false} data: {"message": {"role": "assistant", "content": "!"}, "done": false} data: {"message": {"role": "assistant", "content": ""}, "done": true}
Opt-in

Set stream: false to receive the full response as a single JSON object.

{ "choices": [ { "message": {"role": "assistant", "content": "Hello!"} } ], "usage": {"prompt_tokens": 15, "completion_tokens": 8, "total_tokens": 23} }

Claude and Anthropic messages

The messages endpoint provides an Anthropic-compatible interface (/v1/messages) designed for Claude extensions, coding assistants, and tools like Cline, Roo Code, Continue, Claude Dev, and Cursor.

Endpoint

POST https://ai.kenechiifeanyi.com/v1/messages

Extension configuration

In your extension settings:

  • Provider: Anthropic
  • Base URL: https://ai.kenechiifeanyi.com (or https://ai.kenechiifeanyi.com/v1 depending on extension)
  • API key: Your AI-Gate key
  • Model: Enter any model name (e.g. claude-3-5-sonnet-20241022) or leave as default. AI-Gate routes requests through your configured multi-provider chat fallback chain.

Request format

{ "model": "claude-3-5-sonnet-20241022", "max_tokens": 1024, "system": "You are a helpful coding assistant.", "messages": [ { "role": "user", "content": "Write a python function to compute fibonacci numbers." } ], "stream": true }

Response format

Default

Full support for Anthropic SSE events (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop).

event: message_start data: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-3-5-sonnet-20241022", "stop_reason": null, "usage": {"input_tokens": 25, "output_tokens": 1}}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "def fibonacci(n):"}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}, "usage": {"output_tokens": 30}} event: message_stop data: {"type": "message_stop"}
Opt-in

When stream: false, returns standard Anthropic JSON.

{ "id": "msg_01XFDUDYJgAACzvnptvVoYEL", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)" } ], "model": "claude-3-5-sonnet-20241022", "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 25, "output_tokens": 30 } }

Embeddings

The embeddings endpoint generates vector embeddings for input text. The model is determined automatically by the platform based on the embedding model synced via the admin dashboard.

Endpoint

POST https://ai.kenechiifeanyi.com/v1/embeddings

Request Format

{ "input": "This is the text to embed" }

Pass an array of strings in input to embed multiple texts in a single request.

Response Format

{ "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.0023, -0.0142, 0.0083, ...] } ], "model": "default-embedding-model" }

Usage with RAG

Process your documents through your own embedding step, store the vectors in your vector database, then use AI-Gate for chat completion calls that retrieve and reason over your context.

Image Generation

The image generation endpoint provides an OpenAI-compatible interface (/v1/images/generations) for creating high-fidelity images from text prompts using models like FLUX.1 Schnell, FLUX Realism, Seedream, and SDXL Turbo on Pollinations.

Endpoint

POST https://ai.kenechiifeanyi.com/v1/images/generations

Request Format

{ "prompt": "A futuristic cyberpunk city with neon reflections in rain", "model": "flux", "size": "1024x1024", "n": 1, "response_format": "url" }

Parameters:

  • prompt (required): A text description of the desired image(s).
  • model (optional): The model to use (e.g. flux, flux-realism, seedream, turbo). Defaults to the highest-priority active image model.
  • size (optional): Image dimensions in WIDTHxHEIGHT format (e.g. 1024x1024, 1280x720, 768x1024). Defaults to 1024x1024.
  • n (optional): The number of images to generate (1 to 10). Defaults to 1.
  • response_format (optional): Either "url" (default) or "b64_json" for Base64-encoded image data.
  • async (optional): Set to true to dispatch to background Celery workers and immediately receive a task ID (HTTP 202) for status polling.

Response Format

{ "created": 1728800000, "data": [ { "url": "https://..." } ] }

Video Generation

The video generation endpoint provides an API for generating dynamic video clips from text descriptions using models like Seedance Pro, Wan 2.1, and Google Veo.

Endpoint

POST https://ai.kenechiifeanyi.com/v1/videos/generations

Request Format

{ "prompt": "A cinematic timelapse of a sunset over rolling ocean waves", "model": "seedance-pro", "duration": 5, "aspect_ratio": "16:9" }

Parameters:

  • prompt (required): A detailed prompt describing the action, lighting, and camera motion for the video.
  • model (optional): The video model to use (e.g. seedance-pro, wan, veo). Defaults to the highest-priority active video model.
  • duration (optional): Duration of the generated clip in seconds (e.g. 4, 5, 6). Defaults to 5.
  • aspect_ratio (optional): Framing orientation (e.g. "16:9", "9:16", "1:1"). Defaults to "16:9".
  • async (optional): Set to true to execute via background Celery worker and receive an instant HTTP 202 Accepted response with a task ID to avoid long HTTP waiting states.

Response Format

{ "created": 1728800000, "data": [ { "url": "https://..." } ] }

Audio Generation (Text-to-Speech)

The audio generation endpoints provide an OpenAI-compatible speech synthesis interface (/v1/audio/speech and /v1/audio/generations) for creating spoken audio from text prompts using models like OpenAI Audio, TTS-1, and TTS-1-HD on Pollinations.

Endpoints

POST https://ai.kenechiifeanyi.com/v1/audio/speech POST https://ai.kenechiifeanyi.com/v1/audio/generations

Request Format

{ "input": "AI-Gate provides multi-provider AI routing and automated fallbacks.", "model": "openai-audio", "voice": "nova", "response_format": "mp3", "speed": 1.0 }

Parameters:

  • input or prompt (required): The text to generate audio for (up to 4,096 characters).
  • model (optional): The audio model to use (e.g. openai-audio, tts-1, tts-1-hd). Defaults to the highest-priority active audio model.
  • voice (optional): The voice to use for narration (e.g. nova, alloy, echo, fable, onyx, shimmer). Defaults to nova.
  • response_format (optional): The audio format (e.g. mp3, wav, ogg, aac, flac). Defaults to mp3.
  • speed (optional): The speaking speed between 0.25 and 4.0. Defaults to 1.0.
  • async (optional): Set to true to dispatch synthesis to background Celery workers and immediately receive a task ID (HTTP 202) for status polling.

Response Format

{ "created": 1728800000, "data": [ { "url": "https://gen.pollinations.ai/audio/..." } ] }

Background Worker & Task Polling

Image, audio, and especially video generation can take anywhere from a few seconds to a couple of minutes. To avoid keeping HTTP connections open and prevent gateway or proxy timeouts (such as Cloudflare 524 timeouts), you can offload jobs to our Celery background workers by setting "async": true.

1. Submit Asynchronous Generation Job

Add "async": true to your request body (or pass query parameter ?async=true):

curl -X POST https://ai.kenechiifeanyi.com/v1/videos/generations \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A majestic eagle soaring over snow-capped mountains at sunset", "model": "seedance-pro", "async": true }'

Response (HTTP 202 Accepted):

{ "id": "e0b82e21-0857-4180-a61f-d748f34d1b82", "status": "pending", "created": 1728800000, "media_type": "video", "poll_url": "/v1/tasks/e0b82e21-0857-4180-a61f-d748f34d1b82" }

2. Poll Task Status

Retrieve generation status and the resulting media URL via the task polling endpoint:

GET https://ai.kenechiifeanyi.com/v1/tasks/{task_id}

(Also accessible via GET /v1/images/tasks/{task_id}, GET /v1/videos/tasks/{task_id}, or GET /v1/audio/tasks/{task_id})

curl -X GET https://ai.kenechiifeanyi.com/v1/tasks/e0b82e21-0857-4180-a61f-d748f34d1b82 \ -H "Authorization: Bearer YOUR_API_KEY"

Status Responses:

  • pending / processing: Job is currently queued or generating.
    { "id": "e0b82e21-0857-4180-a61f-d748f34d1b82", "status": "processing", "media_type": "video", "created": 1728800000 }
  • completed: Generation succeeded; includes output media URLs and generation duration.
    { "id": "e0b82e21-0857-4180-a61f-d748f34d1b82", "status": "completed", "media_type": "video", "created": 1728800000, "duration": 8.35, "data": [ { "url": "https://gen.pollinations.ai/video/..." } ] }
  • failed: An upstream issue occurred; includes failure reason.
    { "id": "e0b82e21-0857-4180-a61f-d748f34d1b82", "status": "failed", "media_type": "video", "created": 1728800000, "error": "Upstream video model timed out." }

3. Cancel a Task

You can cancel a pending or in-progress generation job by sending a DELETE request to the task endpoint:

curl -X DELETE https://ai.kenechiifeanyi.com/v1/tasks/e0b82e21-0857-4180-a61f-d748f34d1b82 \ -H "Authorization: Bearer YOUR_API_KEY"

Privacy & Sensitive Data Masking

AI-Gate comes with built-in privacy protection. Sensitive information is automatically masked before being forwarded to upstream AI providers, preventing data leakage while preserving conversation context and reasoning quality.

What Gets Masked

  • API Keys & Tokens: Bearer tokens, OpenAI/OpenRouter keys (sk-...), GitHub tokens, AWS access keys, private keys, and JWTs are replaced with [API_KEY] or [JWT_TOKEN].
  • Passwords & Secrets: Passwords and credentials in config/JSON payloads are masked with [SECRET].
  • Email Addresses: Replaced with [EMAIL].
  • Credit Card Numbers: Replaced with [CREDIT_CARD].
  • Phone Numbers: Replaced with [PHONE_NUMBER].
  • IP Addresses: IPv4 addresses are replaced with [IP_ADDRESS].
  • Social Security Numbers: Replaced with [SSN].

Opt-out Parameter

Masking is enabled by default. If your workload requires sending unmasked raw data to the model, you can opt out by passing "masked": false in the request body.

{ "messages": [ {"role": "user", "content": "My contact is [email protected]"} ], "masked": false }

Limits

The following limits apply to all API requests to protect the gateway and ensure fair usage:

Request body size: 20 MB max Chat messages per request: 128 max Message content length: 200000 characters max Embedding inputs per call: 100 max Embedding input length: 200000 characters max Rate limit: 60 requests per 15 minutes per API key

Requests exceeding any limit will receive an appropriate error response (413 for oversized bodies, 422 for invalid input, 429 for rate limiting).

Quick Start

import httpx response = httpx.post( "https://ai.kenechiifeanyi.com/v1/chat/completions", headers={ "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json", }, json={ "messages": [ {"role": "user", "content": "Explain RAG in simple terms."} ], "stream": False, }, timeout=60.0, ) print(response.json())
// Using Fetch API (built-in) const response = await fetch("https://ai.kenechiifeanyi.com/v1/chat/completions", { method: "POST", headers: { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ messages: [ { role: "user", content: "Explain RAG in simple terms." } ], stream: false, }), }); const data = await response.json(); console.log(data.choices[0].message.content); // --- OR using Axios --- // import axios from "axios"; // const response = await axios.post( // "https://ai.kenechiifeanyi.com/v1/chat/completions", // { // messages: [ // { role: "user", content: "Explain RAG in simple terms." } // ], // stream: false, // }, // { // headers: { // Authorization: "Bearer YOUR_API_KEY", // "Content-Type": "application/json", // }, // } // ); // console.log(response.data.choices[0].message.content);
package main import ( "bytes" "encoding/json" "fmt" "net/http" "time" ) func main() { payload := map[string]interface{}{ "messages": []map[string]string{ {"role": "user", "content": "Explain RAG in simple terms."}, }, "stream": false, } reqBody, _ := json.Marshal(payload) client := &http.Client{Timeout: 60 * time.Second} req, _ := http.NewRequest("POST", "https://ai.kenechiifeanyi.com/v1/chat/completions", bytes.NewBuffer(reqBody)) req.Header.Set("Authorization", "Bearer YOUR_API_KEY") req.Header.Set("Content-Type", "application/json") resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println(result["choices"].([]interface{})[0].(map[string]interface{})["message"].(map[string]interface{})["content"]) }
require "net/http" require "json" uri = URI.parse("https://ai.kenechiifeanyi.com/v1/chat/completions") request = Net::HTTP::Post.new(uri) request["Authorization"] = "Bearer YOUR_API_KEY" request["Content-Type"] = "application/json" request.body = { messages: [ { role: "user", content: "Explain RAG in simple terms." } ], stream: false }.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http| http.request(request) end puts JSON.parse(response.body)["choices"][0]["message"]["content"]
use reqwest::Client; use std::collections::HashMap; #[tokio::main] async fn main() -> Result<(), Box> { let client = Client::new(); let mut messages = Vec::new(); let mut msg = HashMap::new(); msg.insert("role", "user"); msg.insert("content", "Explain RAG in simple terms."); messages.push(msg); let mut body = HashMap::new(); body.insert("messages", messages); body.insert("stream", false); let res = client .post("https://ai.kenechiifeanyi.com/v1/chat/completions") .bearer_auth("YOUR_API_KEY") .json(&body) .send() .await?; let json: serde_json::Value = res.json().await?; println!("{}", json["choices"][0]["message"]["content"]); Ok(()) }
#include <curl/curl.h> #include <string> #include <iostream> int main() { CURL *curl = curl_easy_init(); if (curl) { std::string url = "https://ai.kenechiifeanyi.com/v1/chat/completions"; std::string jsonBody = R"({ "messages": [{"role": "user", "content": "Explain RAG in simple terms."}], "stream": false })"; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: application/json"); std::string authHeader = "Authorization: Bearer YOUR_API_KEY"; headers = curl_slist_append(headers, authHeader.c_str()); curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, jsonBody.c_str()); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) { std::cerr << curl_easy_strerror(res) << std::endl; } curl_slist_free_all(headers); curl_easy_cleanup(curl); } return 0; }
<?php $ch = curl_init("https://ai.kenechiifeanyi.com/v1/chat/completions"); $data = [ "messages" => [ ["role" => "user", "content" => "Explain RAG in simple terms."] ], "stream" => false, ]; curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => [ "Authorization: Bearer YOUR_API_KEY", "Content-Type: application/json", ], CURLOPT_TIMEOUT => 60, ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); echo $result["choices"][0]["message"]["content"];
import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.URI; import java.time.Duration; HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(60)) .build(); String json = """ { "messages": [ {"role": "user", "content": "Explain RAG in simple terms."} ], "stream": false } """; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://ai.kenechiifeanyi.com/v1/chat/completions")) .header("Authorization", "Bearer YOUR_API_KEY") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(json)) .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
curl -X POST https://ai.kenechiifeanyi.com/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messages": [ {"role": "user", "content": "Explain RAG in simple terms."} ], "stream": false }'