Kopro API Documentation v1.5
EN RU
Chat App Studio Sandbox Get API Key

Kopro API Quickstart

Connect your applications directly to Kopro AI using standard HTTP POST requests. Works out of the box with Python requests, JavaScript fetch, or curl.

Authentication & Keys

All API requests must include your personal Kopro API Key in the Authorization header:

Authorization: Bearer kp_live_... (or x-api-key: kp_live_...)

Generate your live API key anytime from Settings → Developer API Key on kopro.mom.

OpenAI SDK Drop-in Compatibility

Kopro is 100% wire-compatible with the standard OpenAI API. You can use official OpenAI SDKs in Python or Node.js by overriding base_url:

from openai import OpenAI

client = OpenAI(
    api_key="kp_live_your_api_key",
    base_url="https://api.kopro.mom/v1"
)

response = client.chat.completions.create(
    model="kopro-2.0",
    messages=[
        {"role": "system", "content": "You are a concise engineering assistant."},
        {"role": "user", "content": "Explain async I/O in 1 sentence."}
    ],
    temperature=0.7
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "kp_live_your_api_key",
  baseURL: "https://api.kopro.mom/v1"
});

const completion = await client.chat.completions.create({
  model: "kopro-2.0",
  messages: [
    { role: "system", content: "You are a concise engineering assistant." },
    { role: "user", content: "Explain async I/O in 1 sentence." }
  ]
});

console.log(completion.choices[0].message.content);

Available Models

Model ID Arch & Footprint Gen Speed (TPS) Best For
kopro-4.0-pro new Qwen3 Coder 30B MoE, 3B active (Q4_K_M, 18.6 GB) on GPU ~66 tok/s Best model. Code, full web pages, design, agents with tool calling. 16k context in coding mode
kopro-4.0-flash new Qwen3 14B (Q4_K_M, 9.0 GB) on GPU ~41 tok/s Fast everyday model with tool calling. Components, chat, quick fixes
kopro-3.0 Llama 3.2 3B (Q4, 2.0 GB) CPU Newest small model, English
kopro-2.0-pro Qwen 2 Math 2B (Q5, 1.7 GB) 12.4 tok/s Smartest 2B • Advanced Math, algebraic proofs, symbolic reasoning, and display LaTeX output
kopro-2.0 Qwen 2.5 Instruct 3B (Q5, 2.2 GB) 9.01 tok/s Next-Gen Frontier Flagship. Complex reasoning, strict code formatting, and high-precision JSON
kopro-flash Llama 1.2B (Q4, 807 MB) 24.16 tok/s Sub-second reflex (445 ms TTFT), continuous ambient voice, and fast streaming

Kopro 4.0 runs on GPUs that start on demand. The first request after a quiet period can take 1 to 2 minutes (cold start); after that, answers start in seconds. With "stream": true the connection is kept alive while it starts.

Query available models programmatically via GET https://api.kopro.mom/v1/models:

GET /v1/models Response
{
  "object": "list",
  "data": [
    {
      "id": "kopro-4.0-pro",
      "object": "model",
      "owned_by": "kopro",
      "description": "30B MoE (3B active) • Best for code, design and agents • tool calling • 16k context"
    },
    {
      "id": "kopro-4.0-flash",
      "object": "model",
      "owned_by": "kopro",
      "description": "14B • Fast everyday model • tool calling • 16k context"
    },
    {
      "id": "kopro-2.0-pro",
      "object": "model",
      "owned_by": "kopro",
      "description": "Smartest 2B • Advanced Math & Mathematical Reasoning"
    },
    {
      "id": "kopro-2.0",
      "object": "model",
      "owned_by": "kopro",
      "description": "Qwen 2.5 3B Instruct (Q5, 2.2 GB) • Complex Reasoning & Code"
    },
    {
      "id": "kopro-flash",
      "object": "model",
      "owned_by": "kopro",
      "description": "1.2B Ultra-Speed (807 MB) • Sub-second reflex"
    }
  ]
}

Request Parameters & Schema

Full payload definition for POST /v1/chat/completions:

Field Type Default Description
model string "kopro-2.0" Target model alias (kopro-4.0-pro, kopro-4.0-flash, kopro-3.0, kopro-2.0-pro, kopro-2.0, kopro-flash)
messages array required List of message objects with role ("system" | "user" | "assistant") and content (string or multimodal array with text and image_url)
stream boolean false Set to true to receive tokens as Server-Sent Events (SSE)
temperature float 0.7 Controls randomness. Lower values are more deterministic; higher values are more creative
max_tokens integer null Maximum tokens to generate before stopping
web_search boolean false Ground response with live web search results and embedded citations
format string null Set to "json" to guarantee valid JSON structured output
tools array null OpenAI-format function definitions. Kopro 4.0 only. See Tool Calling

Stateless Conversations

Maintain full control over conversation state by managing the messages array on your client side and appending new user and assistant turns:

import requests

url = "https://api.kopro.mom/v1/chat/completions"
headers = {
    "Authorization": "Bearer kp_live_your_api_key",
    "Content-Type": "application/json"
}

history = [
    {"role": "user", "content": "I have 2 dogs in my house."},
    {"role": "assistant", "content": "That's lovely! What breeds are they?"}
]

# Append new turn
history.append({"role": "user", "content": "How many pets do I have?"})

payload = {
    "model": "kopro-2.0",
    "messages": history,
    "temperature": 0.7
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
print(data["choices"][0]["message"]["content"])
# => "You have 2 dogs in your house!"
const history = [
  { role: "user", content: "I have 2 dogs in my house." },
  { role: "assistant", content: "That's lovely! What breeds are they?" },
  { role: "user", content: "How many pets do I have?" }
];

const response = await fetch("https://api.kopro.mom/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer kp_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "kopro-2.0",
    messages: history,
    temperature: 0.7
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);
curl -X POST https://api.kopro.mom/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer kp_live_your_api_key" \
  -d '{
    "model": "kopro-2.0",
    "messages": [
      {"role": "user", "content": "Explain quantum entanglement in 1 sentence"}
    ],
    "temperature": 0.7
  }'

Streaming Responses (SSE)

Pass "stream": true in your request body to receive real-time Server-Sent Events (SSE) as tokens are synthesized:

import requests
import json

url = "https://api.kopro.mom/v1/chat/completions"
headers = {
    "Authorization": "Bearer kp_live_your_api_key",
    "Content-Type": "application/json"
}
payload = {
    "model": "kopro-2.0",
    "messages": [{"role": "user", "content": "Write a short poem about code."}],
    "stream": True
}

with requests.post(url, headers=headers, json=payload, stream=True) as resp:
    for line in resp.iter_lines():
        if line and line.startswith(b"data: "):
            raw = line[6:].decode("utf-8").strip()
            if raw == "[DONE]":
                break
            chunk = json.loads(raw)
            token = chunk["choices"][0]["delta"].get("content", "")
            print(token, end="", flush=True)
const resp = await fetch("https://api.kopro.mom/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer kp_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "kopro-2.0",
    messages: [{ role: "user", content: "Write a short poem about code." }],
    stream: true
  })
});

const reader = resp.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  const chunk = decoder.decode(value);
  for (const line of chunk.split("\n")) {
    if (line.startsWith("data: ") && !line.includes("[DONE]")) {
      const parsed = JSON.parse(line.slice(6));
      process.stdout.write(parsed.choices[0].delta.content || "");
    }
  }
}

JSON Mode (Structured Outputs)

Pass "format": "json" to force the model to respond strictly with a valid JSON object. Perfect for building automated agents, schemas, and parsers:

import requests
import json

resp = requests.post(
    "https://api.kopro.mom/v1/chat/completions",
    headers={"Authorization": "Bearer kp_live_your_api_key"},
    json={
        "model": "kopro-2.0",
        "format": "json",
        "messages": [
            {"role": "user", "content": "Extract customer details: 'Alex Mercer, 32, Berlin, alex@mercer.io' into JSON keys: name, age, city, email"}
        ]
    }
)

parsed_json = json.loads(resp.json()["choices"][0]["message"]["content"])
print(parsed_json["city"])  # => "Berlin"
const resp = await fetch("https://api.kopro.mom/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer kp_live_your_api_key",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "kopro-2.0",
    format: "json",
    messages: [
      { role: "user", content: "Extract customer details: 'Alex Mercer, 32, Berlin' into JSON keys: name, age, city" }
    ]
  })
});

const data = await resp.json();
const obj = JSON.parse(data.choices[0].message.content);
console.log(obj.name); // => "Alex Mercer"

Tool Calling (Kopro 4.0)

kopro-4.0-pro and kopro-4.0-flash support native function calling in the OpenAI format, so agent frameworks (OpenAI SDK, LangChain, Cline, Continue, Roo Code) work out of the box. Pass tools; when the model wants one, the reply has tool_calls and finish_reason: "tool_calls". Run the tool, send the result back as a role: "tool" message, and call again.

Python (OpenAI SDK)
import json
from openai import OpenAI

client = OpenAI(base_url="https://api.kopro.mom/v1", api_key="kp_live_...")
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
    },
}]
messages = [{"role": "user", "content": "What is the weather in Tokyo?"}]

reply = client.chat.completions.create(model="kopro-4.0-pro", messages=messages, tools=tools)
msg = reply.choices[0].message
# msg.tool_calls[0].function -> name="get_weather", arguments='{"city": "Tokyo"}'

messages.append(msg)
for call in msg.tool_calls:
    result = {"temp_c": 18, "sky": "light rain"}  # your real tool here
    messages.append({"role": "tool", "tool_call_id": call.id, "name": call.function.name, "content": json.dumps(result)})

final = client.chat.completions.create(model="kopro-4.0-pro", messages=messages, tools=tools)
print(final.choices[0].message.content)  # "It is 18 degrees Celsius in Tokyo with light rain..."

Streaming works with tools too: text arrives as delta.content, tool calls as one delta.tool_calls chunk before the final finish_reason.

Kopro Code for VS Code

Kopro Code is the Kopro 4.0 coding agent inside VS Code. It reads, searches and edits files in your project, creates new ones and runs terminal commands (build, test, git, npm). Every edit and command asks first, with a real diff view. Chats sync with your kopro.mom account, so you can continue them on the web.

Download kopro-code.vsix

StepWhat to do
1Download kopro-code.vsix with the button above.
2In VS Code open Extensions, click ··· at the top, choose Install from VSIX… and pick the file.
3Click the </> Kopro Code icon in the activity bar and log in with your kopro.mom username and password.
4Open a project folder and ask for something: "add a dark mode toggle to the navbar", "fix the failing test", "explain src/api.ts".
FeatureHow
Toolsls, grep, read, edit, write, $ (bash on macOS/Linux, Git Bash or PowerShell on Windows)
ApprovalsAllow / Always allow / Deny on each edit or command. View diff opens the change side by side. Edits are undoable with Ctrl+Z.
Chat with a fileThe gold </> button in the editor title bar (next to Run), or right-click a file in the Explorer.
Anywhere in the windowDrag the view to the bottom panel or secondary sidebar, or open a chat as an editor tab (⧉) and drag it to any split or a new window.
SyncAll chats are saved to your account and listed under chats in VS Code and on the web (marked </>).
UsageThe bar at the top shows your daily generation limit, the same one as in Settings → Limits.
Settingskopro.autoApproveEdits, kopro.autoApproveCommands, kopro.shell, kopro.serverUrl

Pass "web_search": true in your payload to equip the model with live web verification. Kopro queries real-time web databases, extracts factual sources, and embeds markdown citations automatically:

Python Grounding Request
import requests

resp = requests.post(
    "https://api.kopro.mom/v1/chat/completions",
    headers={"Authorization": "Bearer kp_live_your_api_key"},
    json={
        "model": "kopro-2.0",
        "messages": [{"role": "user", "content": "What are the latest developments in fusion energy this week?"}],
        "web_search": True
    }
)
print(resp.json()["choices"][0]["message"]["content"])

Vision & Document Recognition

Kopro AI provides native multimodal capabilities to analyze images (photos, UI screenshots, charts, handwritten or printed text OCR) and parse rich documents (source code, CSVs, markdown, configs, and extracted text).

1. Multimodal Image Recognition (Vision & OCR)

Pass images directly via standard OpenAI-compatible format (image_url containing a public URL or a Base64 data URI). The high-precision vision pipeline performs optical character recognition (OCR), layout extraction, and visual context analysis:

import base64
from openai import OpenAI

client = OpenAI(
    api_key="kp_live_your_api_key",
    base_url="https://api.kopro.mom/v1"
)

# Read and encode local image
with open("screenshot.png", "rb") as image_file:
    base64_image = base64.b64encode(image_file.read()).decode("utf-8")

response = client.chat.completions.create(
    model="kopro-2.0",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Extract all error messages and explain how to fix them:"},
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/png;base64,{base64_image}"}
                }
            ]
        }
    ]
)

print(response.choices[0].message.content)
import fs from "fs";
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "kp_live_your_api_key",
  baseURL: "https://api.kopro.mom/v1"
});

const imageBase64 = fs.readFileSync("diagram.jpg").toString("base64");

const response = await client.chat.completions.create({
  model: "kopro-2.0",
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Explain the architecture described in this diagram:" },
        {
          type: "image_url",
          image_url: { url: `data:image/jpeg;base64,${imageBase64}` }
        }
      ]
    }
  ]
});

console.log(response.choices[0].message.content);
curl -X POST https://api.kopro.mom/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer kp_live_your_api_key" \
  -d '{
    "model": "kopro-2.0",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is written on this receipt and what is the total sum?"},
          {"type": "image_url", "image_url": {"url": "https://example.com/receipt.jpg"}}
        ]
      }
    ]
  }'

2. Document Understanding & Codebase Analysis

Analyze full source code files, CSV data, JSON payloads, or text extracted from PDFs. Simply inject the document contents into the user prompt or leverage the native /api/chat/stream attachment pipeline:

from openai import OpenAI

client = OpenAI(
    api_key="kp_live_your_api_key",
    base_url="https://api.kopro.mom/v1"
)

# Load document content
with open("main.py", "r", encoding="utf-8") as f:
    source_code = f.read()

response = client.chat.completions.create(
    model="kopro-2.0",
    messages=[
        {"role": "system", "content": "You are a Senior Security Auditor."},
        {
            "role": "user",
            "content": f"Review this source file for potential race conditions or vulnerabilities:\n\n```python\n{source_code}\n```"
        }
    ]
)

print(response.choices[0].message.content)
// POST https://api.kopro.mom/api/chat/stream
{
  "chat_id": "chat_1726000000",
  "message": "Analyze sales trends and summarize key outliers.",
  "attached_files": [
    {
      "name": "sales_q3.csv",
      "content": "date,region,revenue,units\n2026-08-01,EU,14200,45\n2026-08-02,US,38100,120",
      "is_image": false,
      "size": 65
    }
  ]
}
Supported Document & Image Formats: Images support PNG, JPEG, and WEBP. Documents accept plain text, Markdown, CSV/TSV, JSON, configuration files (.yaml, .env, .toml), and all major code files.

Image Generation

When prompts contain visual intent like "draw a cyberpunk neon city" or "generate an astronaut on Mars", Kopro produces direct high-resolution 1024x1024 artwork rendered seamlessly via Pollinations:

Direct CDN endpoint format:
https://image.pollinations.ai/prompt/{prompt}?width=1024&height=1024&nologo=true

Key Management API

Manage API keys programmatically using standard user session tokens (Bearer eyJ...) obtained from login:

Key Lifecycle Routes
# 1. List all active API keys
curl https://api.kopro.mom/api/keys \
  -H "Authorization: Bearer YOUR_USER_TOKEN"

# 2. Generate a new API key
curl -X POST https://api.kopro.mom/api/keys \
  -H "Authorization: Bearer YOUR_USER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "CI/CD Deployment Key"}'

# 3. Revoke/Delete an API key by ID
curl -X DELETE https://api.kopro.mom/api/keys/12 \
  -H "Authorization: Bearer YOUR_USER_TOKEN"

Token Usage & Telemetry

Every API call is automatically recorded with token volume, model duration, and latency. You can query your key's usage programmatically at any time:

GET /api/keys/usage
curl https://api.kopro.mom/api/keys/usage \
  -H "Authorization: Bearer kp_live_your_api_key"

Limits & HTTP Error Codes

Status Code Error Reason Resolution
401 Unauthorized Missing or invalid kp_live_... key Ensure your header is Authorization: Bearer kp_live_... or x-api-key: kp_live_...
422 Unprocessable Schema validation failure Check that messages is a non-empty array with valid role and content
500 Server Error Inference engine error Check that the requested model exists and context fits within memory
Context Window & Timeout Limits: The default context window is 2,048 tokens (num_ctx: 2048). Server request execution timeout is capped at 180 seconds.