Kopro API Documentation v1.5
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-1.5",
    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-1.5",
  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 Parameters Speed Best For
kopro-1.5 3 Billion Fast Flagship deep reasoning, code generation, prose, and structured output
kopro-flash 1.2 Billion Sub-second Real-time chat, summarization, high-throughput workers
kopro-1.0 1.5 Billion Fast Classic Kopro personality & light dialogue tasks

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

GET /v1/models Response
{
  "object": "list",
  "data": [
    {
      "id": "kopro-1.5",
      "object": "model",
      "owned_by": "kopro",
      "description": "Flagship 3B Model • Deep Reasoning & Prose"
    },
    {
      "id": "kopro-flash",
      "object": "model",
      "owned_by": "kopro",
      "description": "1.2B Ultra-Speed • Sub-second reflex"
    },
    {
      "id": "kopro-1.0",
      "object": "model",
      "owned_by": "kopro",
      "description": "1.5B Classic Persona"
    }
  ]
}

Request Parameters & Schema

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

Field Type Default Description
model string "kopro-1.5" Target model alias (kopro-1.5, kopro-flash, kopro-1.0)
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

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-1.5",
    "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-1.5",
    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-1.5",
    "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-1.5",
    "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-1.5",
    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-1.5",
        "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-1.5",
    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"

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-1.5",
        "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-1.5",
    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-1.5",
  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-1.5",
    "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-1.5",
    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.