Skip to main content

Introduction

The External API allows you to integrate Junis AI agents into your own applications. Use your API key to invoke agents, manage sessions, and build powerful AI-powered features.
External API requires an active subscription (Basic or Pro). Credits are consumed for each API call.

Base URL

https://api.junis.ai/api/external
For OpenAI-compatible endpoints:
https://api.junis.ai/api/external/v1

Authentication

All External API requests require an API key in the X-API-Key header:
curl -H "X-API-Key: jns_live_xxxxxxxxxxxxxxxx" \
     https://api.junis.ai/api/external/v1/chat/completions
Never expose your API key in client-side code. Use server-side calls or a backend proxy.

API Key Scopes

API keys can be created with specific scopes to limit access:
ScopeDescription
orchestrator:invokeInvoke the main orchestrator via chat completions
agents:listList available agents in organization
agents:invokeInvoke individual agents directly
sessions:readRead session history and messages

Available Endpoints

OpenAI-Compatible

Chat Completions

POST /v1/chat/completions - OpenAI-compatible chat API

Agent Management

Session Management


Quick Start

1. Get Your API Key

  1. Go to Admin > API Keys
  2. Click Create API Key
  3. Select required scopes
  4. Copy and securely store the key (shown only once)

2. Make Your First Call

curl -X POST https://api.junis.ai/api/external/v1/chat/completions \
  -H "X-API-Key: jns_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "junis-orchestrator",
    "messages": [{"role": "user", "content": "Hello, how are you?"}],
    "stream": false
  }'

3. Parse the Response

{
  "id": "cmpl-abc123",
  "object": "chat.completion",
  "created": 1701234567,
  "model": "junis-orchestrator",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! I'm doing well, thank you for asking..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 25,
    "total_tokens": 35
  }
}

SDK Support

OpenAI Python SDK

import openai

client = openai.OpenAI(
    api_key="jns_live_your_api_key",
    base_url="https://api.junis.ai/api/external/v1"
)

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

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

OpenAI Node.js SDK

import OpenAI from 'openai';

const openai = new OpenAI({
  apiKey: 'jns_live_your_api_key',
  baseURL: 'https://api.junis.ai/api/external/v1'
});

const response = await openai.chat.completions.create({
  model: 'junis-orchestrator',
  messages: [{ role: 'user', content: 'Hello!' }]
});

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

Streaming

Enable streaming for real-time responses:
stream = client.chat.completions.create(
    model="junis-orchestrator",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Rate Limits

PlanRequests/minConcurrent requests
Basic605
Pro30020
Rate limit headers are included in all responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

Error Handling

All errors follow a consistent format:
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}

Common Error Codes

CodeStatusDescription
invalid_api_key401API key is invalid or revoked
insufficient_credits402Not enough credits for request
rate_limit_exceeded429Too many requests
scope_not_allowed403API key lacks required scope
agent_not_found404Specified agent doesn’t exist