Documentation Index Fetch the complete documentation index at: https://mintlify.com/InsForge/InsForge/llms.txt
Use this file to discover all available pages before exploring further.
The AI API provides OpenAI-compatible endpoints for chat completions, image generation, and embeddings, powered by OpenRouter with support for multiple AI providers.
Base URL
All AI endpoints are prefixed with /api/ai
Chat Completions
Generate Chat Completion
POST /api/ai/chat/completion
curl -X POST https://your-app.region.insforge.app/api/ai/chat/completion \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
],
"temperature": 0.7,
"maxTokens": 1000
}'
Generate chat completion with any supported model.
Body Parameters
OpenRouter model identifier (e.g., “openai/gpt-4”, “anthropic/claude-3-opus”)
Array of message objects Message role: user, assistant, system, or tool
Message content (nullable for assistant messages with tool_calls)
Tool calls made by assistant (assistant messages only)
ID of tool call being responded to (tool messages only)
Enable streaming response via Server-Sent Events
Controls randomness (0-2)
Maximum tokens to generate
Nucleus sampling parameter (0-1)
System prompt to guide model behavior
Enable extended reasoning (appends :thinking to model ID, Anthropic models only)
Enable web search integration Show Web search properties
Search engine: native (provider built-in), exa (Exa API), or undefined (auto-select)
Maximum search results (1-10)
Custom prompt for search results
Enable PDF file parsing Show File parser properties
PDF engine: pdf-text (free), mistral-ocr ($2/1000 pages), or native (charged as tokens)
Tool definitions for function calling
Tool usage control: auto, none, required, or specific function
Allow parallel tool calls
Response
AI model response content
Tool calls requested by model (when using function calling)
URL citations from web search results
Response metadata Model used for generation
Basic Response
With Web Search
With Function Calling
{
"text" : "The capital of France is Paris. It's located in the north-central part of the country on the Seine River." ,
"metadata" : {
"model" : "openai/gpt-4" ,
"usage" : {
"promptTokens" : 15 ,
"completionTokens" : 28 ,
"totalTokens" : 43
}
}
}
Streaming Chat Completion
POST /api/ai/chat/completion (Streaming)
curl -X POST https://your-app.region.insforge.app/api/ai/chat/completion \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4",
"messages": [{"role": "user", "content": "Tell me a story"}],
"stream": true
}'
Set stream: true to receive Server-Sent Events (SSE) for real-time token streaming.
Response Format
data: {"text": "Once", "done": false}
data: {"text": " upon", "done": false}
data: {"text": " a", "done": false}
data: {"text": " time", "done": false}
data: {"done": true, "metadata": {"usage": {...}}}
Image Generation
Generate Images
POST /api/ai/image/generation
curl -X POST https://your-app.region.insforge.app/api/ai/image/generation \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/dall-e-3",
"prompt": "A serene landscape with mountains and a lake at sunset, photorealistic style"
}'
Generate images using AI models.
Body Parameters
Image generation model (e.g., “openai/dall-e-3”, “stability-ai/stable-diffusion-xl”)
Text description of desired image
Response
Model used for generation
Generated images (URLs or base64 data)
Text content from multimodal models
Number of images generated
Generation metadata including usage
{
"model" : "openai/dall-e-3" ,
"images" : [
{
"type" : "image_url" ,
"image_url" : {
"url" : "https://oaidalleapiprodscus.blob.core.windows.net/private/..."
}
}
],
"count" : 1 ,
"metadata" : {
"model" : "openai/dall-e-3" ,
"revisedPrompt" : "A photorealistic image of a serene mountain landscape..." ,
"usage" : {
"promptTokens" : 12 ,
"completionTokens" : 0 ,
"totalTokens" : 12
}
},
"nextActions" : "Images have been generated successfully. Use the returned URLs to access them."
}
Embeddings
Generate Embeddings
curl -X POST https://your-app.region.insforge.app/api/ai/embeddings \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/text-embedding-ada-002",
"input": "Hello world"
}'
Generate vector embeddings for text.
Body Parameters
Embedding model identifier (e.g., “openai/text-embedding-ada-002”, “google/gemini-embedding-001”)
Single text string or array of strings to embed
Number of dimensions (model-specific)
Response
Single Input
Multiple Inputs
{
"object" : "list" ,
"data" : [
{
"object" : "embedding" ,
"embedding" : [
0.0023064255 ,
-0.009327292 ,
0.015797347 ,
// ... 1536 dimensions total
],
"index" : 0
}
],
"metadata" : {
"model" : "text-embedding-ada-002" ,
"usage" : {
"promptTokens" : 2 ,
"completionTokens" : 0 ,
"totalTokens" : 2
}
}
}
Model Management
List Available Models
curl https://your-app.region.insforge.app/api/ai/models \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Get all available text and image models from OpenRouter (admin only).
Response
{
"text" : [
{
"provider" : "openrouter" ,
"configured" : true ,
"models" : [
{
"id" : "openai/gpt-4" ,
"name" : "GPT-4" ,
"created" : 1687882411 ,
"description" : "GPT-4 by OpenAI" ,
"context_length" : 8192 ,
"pricing" : {
"prompt" : "0.00003" ,
"completion" : "0.00006"
},
"architecture" : {
"input_modalities" : [ "text" ],
"output_modalities" : [ "text" ]
}
}
]
}
],
"image" : [
{
"provider" : "openrouter" ,
"configured" : true ,
"models" : [
{
"id" : "openai/dall-e-3" ,
"name" : "DALL-E 3" ,
"description" : "Image generation by OpenAI" ,
"pricing" : {
"image" : "0.04"
},
"architecture" : {
"input_modalities" : [ "text" ],
"output_modalities" : [ "image" ]
}
}
]
}
]
}
Get Remaining Credits
curl https://your-app.region.insforge.app/api/ai/credits \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Get remaining credits from OpenRouter (admin only).
Response
{
"credits" : 25.50 ,
"usage" : 74.50
}
AI Configuration (Admin)
Create AI Configuration
POST /api/ai/configurations
curl -X POST https://your-app.region.insforge.app/api/ai/configurations \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"inputModality": ["text"],
"outputModality": ["text"],
"provider": "openrouter",
"modelId": "openai/gpt-4",
"systemPrompt": "You are a helpful assistant."
}'
Create AI configuration (admin only).
Body Parameters
Input types: ["text"], ["image"], or both
Output types: ["text"], ["image"], or both
Provider name (e.g., “openrouter”)
System prompt for configuration
List AI Configurations
GET /api/ai/configurations
curl https://your-app.region.insforge.app/api/ai/configurations \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN"
Get all AI configurations (admin only).
Update AI Configuration
PATCH /api/ai/configurations/{id}
curl -X PATCH https://your-app.region.insforge.app/api/ai/configurations/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"systemPrompt": "You are a helpful coding assistant."
}'
Update configuration system prompt (admin only).
Delete AI Configuration
DELETE /api/ai/configurations/{id}
curl -X DELETE https://your-app.region.insforge.app/api/ai/configurations/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN"
Delete AI configuration (admin only).
Usage Tracking
Get Usage Summary
GET /api/ai/usage/summary
curl "https://your-app.region.insforge.app/api/ai/usage/summary?startDate=2024-01-01T00:00:00Z&endDate=2024-01-31T23:59:59Z" \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN"
Get AI usage summary statistics (admin only).
Query Parameters
Filter by configuration ID
Response
{
"totalRequests" : 1250 ,
"totalTokens" : 45000 ,
"totalCost" : 12.50 ,
"byModel" : {
"openai/gpt-4" : {
"requests" : 800 ,
"tokens" : 35000 ,
"cost" : 10.50
},
"openai/gpt-3.5-turbo" : {
"requests" : 450 ,
"tokens" : 10000 ,
"cost" : 2.00
}
}
}
Get Usage Records
curl "https://your-app.region.insforge.app/api/ai/usage?limit=50&offset=0" \
-H "Authorization: Bearer ADMIN_ACCESS_TOKEN"
Get detailed usage records with pagination (admin only).