AI Playground API

OpenAI-compatible endpoints for chat, responses, images, and embeddings

Getting Started

Welcome to the AI Playground API. This service provides OpenAI-compatible access to locally-hosted Mistral language models, SDXL image generation, and embeddings.

Base URL: https://api.playground.8ase0f0ps.com/v1

Quick Start

Call GET /v1/models to see which model is currently loaded, then use that model name in your requests. The server runs one text model at a time — the active model depends on the current mode.

Available Models

Text Models (Mistral via vLLM)

The server runs one text model at a time. The administrator can switch between modes. Use GET /v1/models to discover the currently active model name.

Mode Model Name Underlying Model Parameters Context Best For
extreme extreme Mistral-Small-3.2-24B-Instruct-2506 24B 49K General conversation, reasoning
code code Devstral-Small-2-24B-Instruct-2512 24B 65K Programming, code completion
fast fast Ministral-3-14B-Instruct-2512 14B 98K Quick responses, batched requests
Tip: All text models support tool / function calling via Mistral's native tool-call parser. If your request omits the model field, the gateway fills in the current default automatically.

Image Models

Embedding Models

Authentication

All API requests require a Bearer token in the Authorization header.

Authorization: Bearer pg_your_api_key_here
Security: Never share your API key or commit it to version control.

Available Endpoints

POST /v1/chat/completions

Chat completions (streaming & tool calling supported)

POST /v1/responses Compatible

Responses API with tool support (mapped to chat completions when needed)

POST /v1/embeddings

Generate embeddings for memory and search

POST /v1/images/generations

Generate images using SDXL

GET /v1/models

List available models

Code Examples

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="pg_your_api_key_here",
    base_url="https://api.playground.8ase0f0ps.com/v1"
)

# Discover the active model
models = client.models.list()
active_model = models.data[0].id  # e.g. "extreme", "fast", or "code"
print(f"Active model: {active_model}")

# Chat completion
response = client.chat.completions.create(
    model=active_model,
    messages=[{"role": "user", "content": "Hello!"}]
)

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

Python (Responses API)

response = client.responses.create(
    model="extreme",   # or "fast", "code" — whichever is active
    input="Summarize the project status."
)

print(response.output_text)

Python (Embeddings)

emb = client.embeddings.create(
    model="nomic-embedding",
    input=["searchable memory"]
)

print(emb.data[0].embedding[:5])

JavaScript (Node.js)

const OpenAI = require('openai');

const openai = new OpenAI({
  apiKey: 'pg_your_api_key_here',
  baseURL: 'https://api.playground.8ase0f0ps.com/v1'
});

(async () => {
  // Discover the active model
  const models = await openai.models.list();
  const activeModel = models.data[0]?.id || 'fast';

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

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

cURL (Discover Active Model)

curl https://api.playground.8ase0f0ps.com/v1/models \
  -H "Authorization: Bearer pg_your_api_key_here"

cURL (Chat Completions)

# Use the model name returned by /v1/models (e.g. "extreme", "fast", "code")
curl https://api.playground.8ase0f0ps.com/v1/chat/completions \
  -H "Authorization: Bearer pg_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fast",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

cURL (Responses)

curl https://api.playground.8ase0f0ps.com/v1/responses \
  -H "Authorization: Bearer pg_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "extreme",
    "input": "Write a short welcome message."
  }'

Streaming Responses

Stream tokens for real-time output with chat completions.

response = client.chat.completions.create(
    model="fast",
    messages=[{"role": "user", "content": "Write a story"}],
    stream=True
)

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

Tool / Function Calling

The API supports OpenAI-compatible tool calling. Define tools in your request and the model will respond with structured tool_calls when appropriate.

Note: When tools are present, streaming is automatically disabled to ensure complete tool call arguments. The gateway validates and repairs truncated arguments automatically.

Chat Completions with Tools

response = client.chat.completions.create(
    model="fast",
    messages=[{"role": "user", "content": "What is the weather in Paris?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name"}
                },
                "required": ["location"]
            }
        }
    }],
    tool_choice="auto"
)

# Check if the model wants to call a tool
message = response.choices[0].message
if message.tool_calls:
    for tc in message.tool_calls:
        print(f"Tool: {tc.function.name}")
        print(f"Args: {tc.function.arguments}")

Responses API with Tools

The /v1/responses endpoint also supports tools. Tool calls are returned as function_call output items.

response = client.responses.create(
    model="fast",
    input="Read the file at /tmp/notes.txt",
    tools=[{
        "type": "function",
        "name": "read_file",
        "description": "Read a file from disk",
        "parameters": {
            "type": "object",
            "properties": {
                "path": {"type": "string", "description": "File path"}
            },
            "required": ["path"]
        }
    }]
)

for item in response.output:
    if item.type == "function_call":
        print(f"Call: {item.name}({item.arguments})")

cURL (Tool Calling)

curl https://api.playground.8ase0f0ps.com/v1/chat/completions \
  -H "Authorization: Bearer pg_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "fast",
    "messages": [{"role": "user", "content": "What is 2+2?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "calculator",
        "description": "Evaluate a math expression",
        "parameters": {
          "type": "object",
          "properties": {
            "expression": {"type": "string"}
          },
          "required": ["expression"]
        }
      }
    }]
  }'

Tool Calling Behaviour

Image Generation

import requests

url = "https://api.playground.8ase0f0ps.com/v1/images/generations"
headers = {
    "Authorization": "Bearer pg_your_api_key_here",
    "Content-Type": "application/json"
}

data = {
    "model": "sdxl-1.0",
    "prompt": "a beautiful sunset over mountains",
    "n": 1,
    "size": "1024x1024"
}

response = requests.post(url, headers=headers, json=data)
image_data = response.json()["data"][0]["b64_json"]

Token Usage

Error Handling

Error Response Format

{
  "error": {
    "code": "upstream_http",
    "message": "Upstream request failed.",
    "hint": "Check upstream and retry.",
    "details": "..."
  }
}

Support

For support, questions, or to request an API key: