API Documentation

Introduction

The Zubnet API gives you programmatic access to 350+ AI models for text, image, video, music, voice, and code generation. It's fully compatible with the OpenAI API specification — if you're already using OpenAI, you can switch to Zubnet by changing your base URL and API key.

Base URL

https://api.zubnet.ai/v1

Quick Start

# Using curl
curl https://api.zubnet.ai/v1/chat/completions \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
# Using Python with OpenAI SDK
from openai import OpenAI

client = OpenAI(
    api_key="your-zubnet-api-key",
    base_url="https://api.zubnet.ai/v1"
)

response = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)

Authentication

All API requests require authentication via Bearer token in the Authorization header.

Authorization: Bearer YOUR_API_KEY

You can generate API keys from your account settings. Keep your keys secure — they grant full access to your account.

Using Your Own Provider Keys (BYOK)

You can use your own API keys from supported providers. Add them in your workspace settings and they'll be used automatically for requests to those providers — at zero markup. BYOK is available on plans that support it.

When a BYOK key is configured for a provider, it takes priority over the platform key. No changes are needed to your API requests — the key resolution is fully transparent.

Supported BYOK Providers

Anthropic Google Gemini DeepSeek Mistral Cohere AI21 Nvidia Alibaba Moonshot MiniMax Sambanova Zhipu ElevenLabs Speechify Hume Cartesia Resemble StabilityAI Black Forest Labs Ideogram HiDream PixVerse Vidu Kling Suno ByteDance

Models

GET /v1/models

List all available models.

curl https://api.zubnet.ai/v1/models \
  -H "Authorization: Bearer $ZUBNET_API_KEY"
Response
{
  "object": "list",
  "data": [
    {
      "id": "claude-sonnet-4-20250514",
      "object": "model",
      "created": 1699900000,
      "owned_by": "anthropic"
    },
    {
      "id": "deepseek-chat",
      "object": "model",
      "created": 1699900000,
      "owned_by": "deepseek"
    },
    ...
  ]
}

Chat Completions

POST /v1/chat/completions

Create a chat completion. This is the primary endpoint for text generation, compatible with the OpenAI chat completions format.

Request Body

Parameter Type Description
modelrequired string Model ID to use (e.g., "claude-sonnet-4-20250514", "deepseek-chat", "gemini-2.5-pro")
messagesrequired array Array of message objects with role and content
temperatureoptional number Sampling temperature (0-2). Default: 0.7
max_tokensoptional integer Maximum tokens to generate (1-128000). Default: 4096
streamoptional boolean Stream responses via SSE. Default: true
top_poptional number Nucleus sampling parameter (0-1). Default: 1
frequency_penaltyoptional number Frequency penalty (-2 to 2). Default: 0
presence_penaltyoptional number Presence penalty (-2 to 2). Default: 0
stopoptional string/array Stop sequences

Example Request

curl https://api.zubnet.ai/v1/chat/completions \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "temperature": 0.7,
    "max_tokens": 150
  }'
Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699900000,
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 8,
    "total_tokens": 33
  }
}

Streaming

When stream is true, the response is delivered as Server-Sent Events (SSE). Each event has a named type and a JSON payload:

Event Description
token A text token/delta from the model
reasoning-token An extended thinking token (for models that support reasoning)
call A tool/function call with name and parameters
message Final complete message object (sent when stream finishes)
error Error message if streaming fails
// SSE event format
event: token
data: {"data": "Hello", "attributes": {}}

event: token
data: {"data": " world", "attributes": {}}

event: message
data: {"id": "msg-uuid", "content": "Hello world", ...}

Code Generation

POST /api/ai/completions/code

Generate code from a natural language prompt. Returns a streaming response via Server-Sent Events (SSE).

Request Body

Parameter Type Description
promptrequired string Natural language description of the code to generate
languagerequired string Programming language (e.g., "python", "javascript", "rust")
temperatureoptional number Sampling temperature (0-2)
max_tokensoptional integer Maximum tokens to generate (1-128000)

Example Request

curl https://app.zubnet.ai/api/ai/completions/code \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A function that checks if a number is prime",
    "language": "python"
  }'
This endpoint streams via SSE. You'll receive chunk events with incremental content, followed by a final document event with the complete generated code.
Final Response Object
{
  "object": "code_document",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "model": "claude-sonnet-4-20250514",
  "cost": 1,
  "title": "Prime Number Checker",
  "content": "def is_prime(n): ..."
}

Image Generation

POST /v1/images/generations

Generate images from text prompts using models from FLUX, Stable Diffusion, Ideogram, and more.

Available Models

flux-pro-1.1-ultra flux-pro-1.1 flux-2-pro flux-kontext-pro gen4_image ideogram-v3 hidream-i1-full

Request Body

Parameter Type Description
modelrequired string Image model to use
promptrequired string Text description of the image to generate
noptional integer Number of images to generate. Default: 1
sizeoptional string Image size (e.g., "1024x1024", "1792x1024")
response_formatoptional string "url" or "b64_json". Default: "url"

Example Request

curl https://api.zubnet.ai/v1/images/generations \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux-pro-1.1-ultra",
    "prompt": "A serene mountain lake at sunset, photorealistic",
    "n": 1,
    "size": "1024x1024"
  }'
Response
{
  "created": 1699900000,
  "data": [
    {
      "url": "https://cdn.zubnet.ai/files/abc123.png",
      "revised_prompt": "A serene mountain lake..."
    }
  ]
}

Video Generation

POST /api/ai/videos

Generate videos from text prompts or images. Supports text-to-video, image-to-video, and video-to-video workflows.

Available Models

veo-3.1-generate-001 veo-3.0-generate-001 kling-v2-5-turbo kling-v2-1-pro gen4_turbo gen4_aleph vidu-q2-pro pixverse-v4

Request Body

Parameter Type Description
modelrequired string Video model to use
promptrequired* string Text description of the video. *Not required for lip-sync or upscale models
framesoptional file[] Input images for image-to-video. Max 10MB each (jpg, png, webp)
videooptional file Input video for video-to-video. Max 100MB (mp4, webm, mov)
audiooptional file Audio file for lip-sync models. Max 25MB
aspect_ratiooptional string Aspect ratio (e.g., "16:9", "9:16", "1:1")
durationoptional integer Video duration in seconds

Example: Text-to-Video

curl https://app.zubnet.ai/api/ai/videos \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "veo-3.1-generate-001",
    "prompt": "A drone shot flying over a coral reef at golden hour",
    "aspect_ratio": "16:9",
    "duration": 8
  }'

Example: Image-to-Video

curl https://app.zubnet.ai/api/ai/videos \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -F "model=kling-v2-5-turbo" \
  -F "prompt=Camera slowly zooms in" \
  -F "frames=@my-image.png"
Video generation is asynchronous. The response includes a state field (“processing”, “completed”, “failed”) and a progress percentage. Poll the library endpoint to check completion status.
Response
{
  "object": "video",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "model": "veo-3.1-generate-001",
  "state": "processing",
  "progress": 0,
  "cost": 5,
  "output_file": null,
  "created_at": "2026-02-25T12:00:00Z"
}

Video Understanding

Analyze video content using AI. Submit a video URL for analysis and poll for results. Supports multiple analysis types.

POST /api/ai/video-understanding

Submit a video for AI analysis. Returns a job ID that you can poll for results.

Request Body

Parameter Type Description
video_urlrequired string Public HTTPS URL of the video to analyze
typeoptional string Analysis type: summary (default), topics, chapters, or highlights

Example Request

curl https://app.zubnet.ai/api/ai/video-understanding \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "video_url": "https://example.com/video.mp4",
    "type": "summary"
  }'
Response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued"
}
GET /api/ai/video-understanding/{jobId}

Check the status of a video analysis job.

Response (completed)
{
  "status": "completed",
  "result": {
    "type": "summary",
    "content": "The video shows a product demonstration..."
  }
}
Video URLs must be publicly accessible HTTPS links. Private/internal URLs are rejected for security. Results are cached for 1 hour.

Music Composition

POST /api/ai/compositions

Generate original music from text descriptions, lyrics, or style tags.

Available Models

suno/v5 suno/v4.5-plus suno/v4.5 suno/v4 lyria-002

Request Body

Parameter Type Description
modelrequired string Music model to use
promptoptional string Description of the music or lyrics to set
tagsoptional string Genre and style tags (e.g., "lo-fi, chill, jazz")
instrumentaloptional boolean Generate instrumental only (no vocals). Default: false

Example Request

curl https://app.zubnet.ai/api/ai/compositions \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "suno/v5",
    "prompt": "An upbeat synthwave track about coding at 3am",
    "tags": "synthwave, electronic, upbeat",
    "instrumental": true
  }'
Suno models typically return 2 composition variants per request. Lyria returns a single 30-second clip at 48kHz.
Response
[
  {
    "object": "composition",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "model": "suno/v5",
    "title": "Midnight Code",
    "tags": "synthwave, electronic, upbeat",
    "cost": 2,
    "output_file": {
      "url": "https://cdn.zubnet.ai/files/abc123.mp3"
    }
  },
  {
    "object": "composition",
    "id": "550e8400-e29b-41d4-a716-446655440001",
    // ... second variant
  }
]

Sound Effects

POST /api/ai/sound-effects

Generate sound effects from text descriptions.

Request Body

Parameter Type Description
modelrequired string Sound effect model to use
promptrequired string Description of the sound effect to generate

Example Request

curl https://app.zubnet.ai/api/ai/sound-effects \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sound-effect-model",
    "prompt": "Thunder rumbling in the distance followed by heavy rain"
  }'
Response
{
  "object": "sound_effect",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "model": "sound-effect-model",
  "cost": 1,
  "output_file": {
    "url": "https://cdn.zubnet.ai/files/abc123.mp3"
  }
}

Text-to-Speech

POST /v1/audio/speech

Convert text to natural-sounding speech audio using voices from ElevenLabs, Cartesia, Speechify, and more.

Parameter Type Description
modelrequired string TTS model (e.g., "tts-1", "tts-1-hd", "elevenlabs")
inputrequired string Text to convert to speech (max 5000 characters)
voicerequired string Voice ID to use (e.g., "alloy", "echo", "nova", or a custom voice ID)
response_formatoptional string Audio format: mp3, opus, aac, flac. Default: mp3

Example Request

curl https://api.zubnet.ai/v1/audio/speech \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1-hd",
    "input": "Welcome to Zubnet, the future of AI.",
    "voice": "nova"
  }' --output speech.mp3

Transcription

POST /v1/audio/transcriptions

Transcribe audio to text.

Parameter Type Description
modelrequired string Transcription model (e.g., "whisper-1")
filerequired file Audio file to transcribe. Max 25MB (mp3, mp4, wav, webm, ogg, flac)
languageoptional string Language code (e.g., "en", "fr", "es")

Example Request

curl https://api.zubnet.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -F "model=whisper-1" \
  -F "file=@recording.mp3"
Response
{
  "object": "transcription",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "model": "whisper-1",
  "content": "Hello, this is a test recording..."
}

Voice Isolation

POST /api/ai/isolated-voices

Extract clean vocals from audio, removing background noise and music. Powered by ElevenLabs.

Parameter Type Description
filerequired file Audio file. Max 25MB (mp3, mp4, wav, m4a, webm, ogg, flac)

Example Request

curl https://app.zubnet.ai/api/ai/isolated-voices \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -F "file=@noisy-recording.mp3"
Response
{
  "object": "isolated_voice",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "cost": 1,
  "input_file": {
    "url": "https://cdn.zubnet.ai/files/input.mp3"
  },
  "output_file": {
    "url": "https://cdn.zubnet.ai/files/isolated.mp3"
  }
}

Stem Separation

POST /api/ai/stem-separations

Separate audio into individual stems (vocals, drums, bass, guitar, piano, other). Powered by ElevenLabs.

Parameter Type Description
filerequired file Audio file. Max 25MB (mp3, mp4, wav, m4a, webm, ogg, flac)
stem_variationoptional string Separation mode. Default: "six_stems_v1" (vocals, drums, bass, guitar, piano, other)

Example Request

curl https://app.zubnet.ai/api/ai/stem-separations \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -F "file=@song.mp3"
Response
{
  "object": "stem_separation",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "cost": 1,
  "input_file": {
    "url": "https://cdn.zubnet.ai/files/song.mp3"
  },
  "output_file": {
    "url": "https://cdn.zubnet.ai/files/stems.zip"
  }
}

Voices

Create and manage custom voices for text-to-speech generation.

POST /api/voices

Create a custom voice by uploading audio samples.

GET /api/voices

List all voices available in your workspace, including custom voices you've created.

PUT /api/voices/{id}

Update a custom voice (name, settings).

DELETE /api/voices/{id}

Delete a custom voice.

Custom voice IDs can be used in the voice parameter of the Text-to-Speech endpoint.

Embeddings

POST /v1/embeddings

Create text embeddings for semantic search and similarity.

Parameter Type Description
modelrequired string Embedding model (e.g., "text-embedding-3-small")
inputrequired string/array Text to embed (string or array of strings)

Example Request

curl https://api.zubnet.ai/v1/embeddings \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog"
  }'

Knowledge Bases

Create and manage knowledge bases for retrieval-augmented generation (RAG). Upload documents (PDF, DOCX, TXT, Markdown) or add web URLs and raw text, then query them in your chat completions.

POST /api/knowledge-bases

Create a new knowledge base.

Request Body

Parameter Type Description
namerequired string Name of the knowledge base
descriptionoptional string Description of the knowledge base

Example: Create a Knowledge Base

curl https://app.zubnet.ai/api/knowledge-bases \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My KB",
    "description": "Optional description"
  }'
Response
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "My KB",
  "description": "Optional description",
  "status": "active"
}
GET /api/knowledge-bases

List all knowledge bases in your workspace.

Response
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "My KB",
    "description": "Optional description",
    "status": "active"
  },
  ...
]
GET /api/knowledge-bases/{id}

Get details of a specific knowledge base, including its documents.

DELETE /api/knowledge-bases/{id}

Delete a knowledge base and all its documents.

POST /api/knowledge-bases/{id}/documents

Ingest a document into a knowledge base. Supports file uploads, URLs, and raw text.

Request Body

Parameter Type Description
fileoption 1 file Multipart file upload (PDF, DOCX, TXT, MD — max 10MB)
titlerequired string Document title (required for URL and text types)
typeoption 2/3 string "url" or "text" (for non-file ingestion)
urloption 2 string URL to fetch and ingest (when type is "url")
contentoption 3 string Raw text content to ingest (when type is "text")

Example: Ingest a File

curl https://app.zubnet.ai/api/knowledge-bases/550e8400-.../documents \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -F "file=@report.pdf"

Example: Ingest a URL

curl https://app.zubnet.ai/api/knowledge-bases/550e8400-.../documents \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Zubnet Docs",
    "type": "url",
    "url": "https://zubnet.ai/developers.html"
  }'

Example: Ingest Raw Text

curl https://app.zubnet.ai/api/knowledge-bases/550e8400-.../documents \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Company Policy",
    "type": "text",
    "content": "All employees must complete security training annually..."
  }'
GET /api/knowledge-bases/{id}/documents

List all documents in a knowledge base.

DELETE /api/knowledge-bases/{id}/documents/{docId}

Delete a specific document from a knowledge base.

GET /api/knowledge-bases/{id}/documents/{docId}/content

Read the extracted text content of a specific document.

Reranking

POST /v1/reranking

Rerank a list of documents by relevance to a query. Useful for improving search results, RAG pipelines, and recommendation systems.

Available Models

rerank-v4.0-pro rerank-v4.0-fast jina-reranker-v3 jina-reranker-m0 rerank-2.5 rerank-2.5-lite

Request Body

Parameter Type Description
modelrequired string Reranking model to use
queryrequired string The search query to rank documents against
documentsrequired array Array of document strings to rerank
top_noptional integer Number of top results to return. Default: all

Example Request

curl https://api.zubnet.ai/v1/reranking \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-v4.0-pro",
    "query": "How do I reset my password?",
    "documents": [
      "To reset your password, go to Settings > Security > Change Password.",
      "Our pricing plans start at $9/month for individuals.",
      "Password requirements: minimum 8 characters, one uppercase letter.",
      "Contact support at help@example.com for account issues."
    ],
    "top_n": 3
  }'
Response
{
  "object": "list",
  "results": [
    {
      "index": 0,
      "relevance_score": 0.953
    },
    {
      "index": 2,
      "relevance_score": 0.714
    },
    {
      "index": 3,
      "relevance_score": 0.389
    }
  ],
  "model": "rerank-v4.0-pro"
}
Results are sorted by relevance score in descending order. The index field refers to the position of each document in the original input array.

Library

The library is where all generated content lives — images, videos, compositions, code documents, transcriptions, and more. Use it to list items, check async generation status, update metadata, and manage your content.

GET /api/library/{type}

List items in your library by content type.

Content Types

images videos compositions sound-effects documents code-documents speeches transcriptions isolated-voices stem-separations conversations

Query Parameters

Parameter Type Description
limitoptional integer Results per page (max 100)
starting_afteroptional string Cursor for forward pagination (item UUID)
ending_beforeoptional string Cursor for backward pagination (item UUID)
sortoptional string Sort field and direction (e.g., "created_at:desc")
queryoptional string Full-text search (max 255 characters)
modeloptional string Filter by model used for generation
Response
{
  "object": "list",
  "data": [
    {
      "id": "550e8400-...",
      "object": "video",
      "model": "veo-3.1-generate-001",
      "title": "Coral reef drone shot",
      "state": 3,
      "progress": 100,
      "cost": 5,
      "output_file": {
        "url": "https://cdn.zubnet.ai/files/abc123.mp4",
        "size": 8421376,
        "extension": "mp4"
      },
      "created_at": "2026-03-01T12:00:00Z"
    },
    ...
  ]
}
GET /api/library/{type}/{id}

Get a single library item by ID. This is the primary endpoint for polling async generation status.

Generation States

State Value Description
draft 0 Not yet submitted
queued 1 Waiting to be processed
processing 2 Currently generating
completed 3 Done — output_file is available
failed 4 Generation failed

Polling Pattern

# 1. Start async generation
curl -X POST https://app.zubnet.ai/api/ai/videos \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "veo-3.1-generate-001", "prompt": "A coral reef"}'
# Returns: {"id": "550e8400-...", "state": 1, ...}

# 2. Poll for completion
curl https://app.zubnet.ai/api/library/videos/550e8400-... \
  -H "Authorization: Bearer $ZUBNET_API_KEY"
# Returns: {"state": 2, "progress": 45, ...}  (still processing)
# Returns: {"state": 3, "progress": 100, "output_file": {"url": "..."}}  (done!)
Pagination is cursor-based. Use the id of the last item in starting_after to get the next page. There are no offset/page parameters.
POST /api/library/{type}/{id}

Update a library item's metadata.

Parameter Type Description
titleoptional string Item title
visibilityoptional integer 0 (private) or 1 (public)
is_favoritedoptional boolean Add or remove from favorites
metaoptional object Custom metadata (genre, mood, tags, description, author, etc.)
DELETE /api/library/{type}/{id}

Delete a library item and its associated files.

GET /api/library/{type}/count

Get the total count of items for a content type. Supports the same query and model filters as the list endpoint.

Assistants

Assistants are reusable chat presets with a custom name, model, system prompt, and settings. Use them to create specialized AI personas for different tasks.

POST /api/assistants

Create a new assistant.

GET /api/assistants

List all assistants in your workspace.

PUT /api/assistants/{id}

Update an assistant's configuration (name, model, system prompt, settings).

DELETE /api/assistants/{id}

Delete an assistant.

MCP Store

Browse and activate MCP (Model Context Protocol) servers to give your agents extended tool capabilities — from web search and data access to code execution and third-party integrations.

GET /api/mcp-store/servers

Browse the MCP server catalog.

Query Parameters

Parameter Type Description
categoryoptional string Filter by category (search, data, developer, infrastructure, communication, commerce, creative, productivity, social, utilities)
queryoptional string Search by name or description
Response
{
  "object": "list",
  "data": [
    {
      "id": "550e8400-...",
      "name": "GitHub",
      "description": "Access GitHub repositories, issues, and pull requests",
      "category": "developer",
      "config_schema": [
        {"name": "api_key", "type": "secret", "label": "API Key", "required": true}
      ],
      "tools": ["list_repos", "create_issue", "search_code"],
      "is_official": true
    },
    ...
  ]
}
POST /api/mcp-store/activations

Activate an MCP server for your workspace. Provide configuration values (API keys, etc.) as defined by the server's config_schema.

Request Body

Parameter Type Description
server_idrequired string UUID of the MCP server to activate
configoptional object Configuration values matching the server's config_schema

Example Request

curl https://app.zubnet.ai/api/mcp-store/activations \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": "550e8400-e29b-41d4-a716-446655440000",
    "config": {
      "api_key": "ghp_xxxxxxxxxxxx"
    }
  }'
Response (201 Created)
{
  "id": "act-uuid-...",
  "server_id": "550e8400-...",
  "status": 1,
  "config": {
    "api_key": "โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข"
  },
  "server": {
    "name": "GitHub",
    ...
  },
  "created_at": "2026-03-01T12:00:00Z"
}
Secret fields in the config are masked in API responses. Each workspace can only activate a given server once. The returned id is the activation_id you use when linking MCP servers to agents.
GET /api/mcp-store/activations

List all MCP servers activated in your workspace.

PUT /api/mcp-store/activations/{id}

Update an activation's configuration or status.

DELETE /api/mcp-store/activations/{id}

Deactivate an MCP server from your workspace.

Agents

Create and manage autonomous AI agents that operate across communication channels. Agents can respond to messages on Telegram and Discord, run on scheduled triggers, and leverage knowledge bases and MCP servers for extended capabilities.

POST /api/agents

Create a new agent.

Request Body

Parameter Type Description
namerequired string Agent name (max 64 characters)
modelrequired string Model ID to use (e.g., "claude-sonnet-4-20250514", "deepseek-chat")
system_promptoptional string Custom system prompt defining the agent's behavior and personality
modeoptional string "quick" or "advanced". Default: "quick"
avataroptional string Avatar URL (max 512 characters)

Example Request

curl https://app.zubnet.ai/api/agents \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Support Bot",
    "model": "claude-sonnet-4-20250514",
    "system_prompt": "You are a friendly support agent. Answer questions clearly and concisely.",
    "mode": "advanced"
  }'
Response (201 Created)
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Support Bot",
  "slug": "support-bot",
  "avatar": null,
  "model": "claude-sonnet-4-20250514",
  "system_prompt": "You are a friendly support agent...",
  "status": 1,
  "mode": "advanced",
  "permissions": {
    "time_windows": [],
    "frequency_cap": {
      "max_messages_per_hour": 60,
      "max_messages_per_day": 500
    },
    "channel_preferences": {},
    "allowed_actions": {
      "can_use_tools": true,
      "can_access_kb": true,
      "max_tool_calls_per_message": 5
    }
  },
  "cost": 0,
  "last_active_at": null,
  "created_at": 1709136000,
  "updated_at": null,
  "user": {
    "id": "a1b2c3d4-...",
    "first_name": "Jane",
    "last_name": "Doe",
    "avatar": "https://cdn.zubnet.ai/files/avatar.jpg"
  },
  "channels": []
}
GET /api/agents

List all agents in the workspace. Supports pagination and filtering.

Parameter Type Description
limitquery integer Results per page. Default: 25
cursorquery string Pagination cursor
sortquery string "name", "created_at", or "last_active_at". Default: "created_at"
directionquery string "asc" or "desc"
statusquery integer Filter by status: 0 (inactive), 1 (active), 2 (paused)
Response
{
  "object": "list",
  "data": [
    {
      "id": "550e8400-...",
      "name": "Support Bot",
      "slug": "support-bot",
      "model": "claude-sonnet-4-20250514",
      "status": 1,
      "mode": "advanced",
      "cost": 12.50,
      "last_active_at": 1709222400,
      "created_at": 1709136000,
      ...
    }
  ]
}
GET /api/agents/{id}

Get full details of a specific agent, including its channels, linked MCP servers, and knowledge bases.

PUT /api/agents/{id}

Update an agent. All fields are optional — only provided fields are changed.

Request Body

Parameter Type Description
nameoptional string Agent name (max 64)
modeloptional string Model ID
system_promptoptional string|null System prompt (set to null to clear)
statusoptional integer 0 (inactive), 1 (active), or 2 (paused)
modeoptional string "quick" or "advanced"
permissionsoptional object Agent permissions (see below)

Permissions Object

{
  "permissions": {
    "time_windows": [
      {
        "days": [1, 2, 3, 4, 5],  // 0=Sun, 6=Sat
        "timezone": "America/New_York",
        "start_hour": 9,            // 0-23
        "end_hour": 17              // 1-24
      }
    ],
    "frequency_cap": {
      "max_messages_per_hour": 60,    // 1-1000
      "max_messages_per_day": 500     // 1-10000
    },
    "channel_preferences": {
      "default_channel": "telegram",
      "proactive_channels": ["telegram", "discord"]
    },
    "allowed_actions": {
      "can_use_tools": true,
      "can_access_kb": true,
      "max_tool_calls_per_message": 5  // 0-50
    }
  }
}
DELETE /api/agents/{id}

Delete an agent. This also removes all its channels, triggers, messages, and integrations.

Integrations

POST /api/agents/{id}/knowledge-bases

Link a knowledge base to an agent for RAG-powered responses. Body: { "knowledge_base_id": "uuid" }

DELETE /api/agents/{id}/knowledge-bases/{kid}

Unlink a knowledge base from an agent.

POST /api/agents/{id}/mcp-servers

Link an MCP server to an agent for extended tool use. Body: { "activation_id": "uuid" }

DELETE /api/agents/{id}/mcp-servers/{activationId}

Unlink an MCP server from an agent.

GET /api/agents/{id}/messages

Retrieve conversation history for an agent.

Parameter Type Description
limitquery integer Number of messages to return. Default: 25, max: 100
Response
{
  "object": "list",
  "data": [
    {
      "id": "msg-uuid-...",
      "direction": "inbound",
      "content": "How do I reset my password?",
      "external_user_name": "john_doe",
      "cost": 0,
      "model": null,
      "created_at": 1709222400
    },
    {
      "id": "msg-uuid-...",
      "direction": "outbound",
      "content": "Go to Settings > Security > Change Password...",
      "cost": 0.25,
      "model": "claude-sonnet-4-20250514",
      "created_at": 1709222401
    }
  ]
}
Agents require the Agents feature to be enabled on your plan. Plan limits apply to the number of agents, channels per agent, and triggers per agent.

Agent Channels

Connect agents to communication platforms. Each agent supports one channel per type (one Telegram bot, one Discord bot).

POST /api/agents/{id}/channels

Add a communication channel to an agent.

Request Body

Parameter Type Description
typerequired string "telegram" or "discord"
tokenrequired string Bot token from Telegram BotFather or Discord Developer Portal (max 256)

Example Request

curl https://app.zubnet.ai/api/agents/550e8400-.../channels \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "telegram",
    "token": "7123456789:AAH..."
  }'
Response (201 Created)
{
  "id": "ch-uuid-...",
  "type": "telegram",
  "status": 1,
  "metadata": {},
  "last_error": null,
  "last_message_at": null,
  "created_at": 1709136000
}
Bot tokens are validated against the platform API before activation and encrypted at rest. For Telegram, a webhook is automatically configured. Channel status: 0 = inactive, 1 = active, 2 = error.
GET /api/agents/{id}/channels

List all channels connected to an agent.

DELETE /api/agents/{id}/channels/{channelId}

Remove a channel from an agent.

Agent Triggers

Automate agent actions with triggers. Scheduled triggers use cron expressions to run at specific times; event triggers fire in response to external events.

POST /api/agents/{id}/triggers

Create an automated trigger for an agent.

Request Body

Parameter Type Description
namerequired string Trigger name (max 128)
typerequired string "scheduled" or "event"
promptrequired string The prompt sent to the agent when the trigger fires
cron_expressionoptional string Cron schedule (e.g., "0 9 * * 1-5" for weekdays at 9am)
timezoneoptional string IANA timezone for cron evaluation. Default: "UTC"
channel_idoptional string Channel to send trigger output to

Example: Daily Summary Trigger

curl https://app.zubnet.ai/api/agents/550e8400-.../triggers \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily Summary",
    "type": "scheduled",
    "prompt": "Summarize the key metrics for today and send them to the team.",
    "cron_expression": "0 18 * * 1-5",
    "timezone": "America/New_York"
  }'
Response (201 Created)
{
  "id": "tr-uuid-...",
  "name": "Daily Summary",
  "type": "scheduled",
  "status": 1,
  "cron_expression": "0 18 * * 1-5",
  "timezone": "America/New_York",
  "prompt": "Summarize the key metrics for today...",
  "channel_id": null,
  "last_run_at": null,
  "next_run_at": 1709236800,
  "run_count": 0,
  "created_at": 1709136000
}
GET /api/agents/{id}/triggers

List all triggers for an agent.

PUT /api/agents/{id}/triggers/{triggerId}

Update a trigger. All fields are optional. Set status to 0 to disable or 1 to enable.

DELETE /api/agents/{id}/triggers/{triggerId}

Delete a trigger.

Scheduled triggers are executed asynchronously via a message queue. Each execution checks that the agent is active and the workspace has sufficient credits before processing.

Workspaces

Workspaces are the organizational unit for your team. Each workspace has its own credit balance, subscription, API keys, and members. Manage workspaces, invite team members, and track usage.

POST /api/workspaces

Create a new workspace.

Parameter Type Description
namerequired string Workspace name (max 50 characters)
Response (201 Created)
{
  "id": "550e8400-...",
  "name": "My Team",
  "subscription": null,
  "api_spending_limit": null,
  "api_spending_current": 0,
  "owner": { "id": "...", "email": "..." },
  "created_at": "2026-03-01T12:00:00Z"
}
POST /api/workspaces/{id}

Update a workspace's settings. Requires workspace manage permission.

Parameter Type Description
nameoptional string Workspace name (max 50 characters)
api_spending_limitoptional number Monthly API spending cap (null for unlimited)
{provider}_api_keyoptional string BYOK API key for a provider (e.g., openai_api_key, anthropic_api_key)
DELETE /api/workspaces/{id}

Delete a workspace. Requires workspace manage permission.

POST /api/workspaces/{id}/invitations

Invite a user to join the workspace by email. Maximum 20 pending invitations per workspace.

Parameter Type Description
emailrequired string Email address of the user to invite
DELETE /api/workspaces/{id}/invitations/{invitationId}

Cancel a pending invitation.

DELETE /api/workspaces/{id}/users/{userId}

Remove a member from the workspace, or leave the workspace by using your own user ID.

GET /api/workspaces/{id}/logs/usage

List aggregated usage statistics for the workspace. Supports cursor-based pagination.

GET /api/workspaces/{id}/logs/usage/items

List itemized usage entries (completed library items with cost > 0). Each entry includes type, model, title, cost, and timestamp.

GET /api/workspaces/{id}/logs/usage/items/count

Get the total count of usage items.

Usage and workspace management endpoints require workspace manage permission (workspace owner or admin).

Conversations

Conversations group chat messages into sessions. Create a conversation first, then send messages to it. Conversations can also be managed through the Library API using the conversations content type.

POST /api/ai/conversations

Create a new conversation. Returns the conversation object with an empty message list.

Response
{
  "object": "conversation",
  "id": "550e8400-...",
  "title": null,
  "cost": 0,
  "messages": [],
  "created_at": "2026-03-01T12:00:00Z"
}
POST /api/ai/conversations/{id}/messages

Send a message to a conversation and receive an AI response via Server-Sent Events (SSE). See the Chat Completions section for SSE event format details.

Request Body

Parameter Type Description
modelrequired string Model to use for the response
contentoptional string Message text
assistant_idoptional string UUID of an assistant to use for this message
parent_idoptional string UUID of a parent message (for branching conversations)
fileoptional file Attachment (images, documents, audio/video — max 25MB)
recordingoptional file Voice recording (mp3, wav, webm, ogg — max 10MB)

Example Request

curl https://app.zubnet.ai/api/ai/conversations/550e8400-.../messages \
  -H "Authorization: Bearer $ZUBNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "content": "Explain quantum computing in simple terms"
  }'
Messages are streamed via SSE. Use multipart/form-data when uploading files. To list or delete conversations, use the Library API with type conversations.

Account

Manage your user profile and generate API keys programmatically.

PUT /api/account

Update your profile information.

Parameter Type Description
first_nameoptional string First name (max 50 characters)
last_nameoptional string Last name (max 50 characters)
languageoptional string Preferred language code (e.g., "en", "fr")
preferencesoptional object User preference settings
POST /api/account/rest-api-keys

Generate a new API key. Requires password confirmation for security. The full API key is returned only once in this response — store it securely.

Parameter Type Description
current_passwordrequired string Your current account password
Response
{
  "id": "550e8400-...",
  "first_name": "Jane",
  "last_name": "Doe",
  "email": "jane@example.com",
  "api_key": "zub_live_a1b2c3d4e5f6..."
}
The api_key value is shown in full only in this response. Subsequent API calls return a masked version. Treat it like a password.

Billing

Browse available plans, view order history, initiate checkout, and manage subscriptions.

GET /api/billing/plans

List available subscription plans.

Parameter Type Description
billing_cycleoptional string Filter by billing cycle
GET /api/billing/orders

List orders for the current workspace. Supports cursor-based pagination.

Parameter Type Description
statusoptional string Filter by order status
billing_cycleoptional string Filter by billing cycle
POST /api/billing/checkout

Start a checkout for a subscription plan or credit purchase. Requires workspace manage permission.

Parameter Type Description
idoptional string UUID of the plan to subscribe to (required if no amount)
amountoptional integer Credit purchase amount in cents (min 1000, required if no id)
gatewayoptional string Payment gateway: stripe or paypal
DELETE /api/billing/subscription

Cancel the current workspace subscription. Requires workspace manage permission.

Content Reports

Report inappropriate or policy-violating content in the public library.

POST /api/content-reports

Submit a content report. Each user can only report a given item once.

Parameter Type Description
item_idrequired string UUID of the library item to report
reasonrequired integer Reason code: 0 (spam), 1 (harassment), 2 (violence), 3 (sexual content), 4 (other)
descriptionoptional string Additional details (max 2000 characters)
Response (201 Created)
{
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
Duplicate reports (same user + same item) return a 409 Conflict error.

Errors

The API uses standard HTTP status codes and returns detailed error messages.

Code Description
400 Bad Request — Invalid parameters
401 Unauthorized — Invalid or missing API key
403 Forbidden — Insufficient credits or model not available on your plan
404 Not Found — Model or resource not found
413 Payload Too Large — File exceeds size limit
429 Too Many Requests — Rate limit exceeded
500 Internal Server Error
503 Service Unavailable — Temporary overload
Error Response Format
{
  "error": {
    "message": "Invalid API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}

Rate Limits

Rate limits vary by plan. Headers are included in every response:

Header Description
X-RateLimit-Limit Requests allowed per minute
X-RateLimit-Remaining Requests remaining in current window
X-RateLimit-Reset Unix timestamp when limit resets

If you hit a rate limit, wait until the reset time or contact us to increase your limits.

Need Help?

We're Here for You

Questions about the API? Check our FAQ or reach out directly.