API Reference

Integrate Wiser Lab's secure multi-node gateway into your automated production environments with minimal configuration.

Authentication

The Wiser Lab API uses Bearer tokens to authenticate requests. You can generate and rotate these keys securely inside your Profile dashboard.

Security Notice: All API requests must be routed over HTTPS. Requests made over unencrypted HTTP will be rejected automatically by the gateway router.
# Pass token in the HTTP Header Authorization: Bearer wsl-...

Base URL

All gateway request mappings share a standardized public endpoint structure. Strip away upstream route complexities and address the secure proxy matrix directly.

# Production Gateway Endpoint https://api.wiserlab.ai

Create Chat Completion

Proxy requests effortlessly using standard OpenAI-structured JSON schema payloads. Wiser Lab dynamically validates credentials, optimizes processing overhead, and executes models natively down to isolated computing nodes.

Request Parameters
model string — Required. The system routing model identifier (e.g., wiser-core-ultra).
messages array — Required. A list of message objects representing the conversation history.
stream boolean — Optional. Defaults to false. If true, server-sent events will be initialized.
POST /v1/chat/completions cURL
curl -X POST https://api.wiserlab.ai/v1/chat/completions \
  -H "Authorization: Bearer wsl-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wiser-core-ultra",
    "messages": [
      {"role": "user", "content": "Hello"}
    ],
    "stream": true
  }'
Python (OpenAI SDK) Python
import openai

client = openai.OpenAI(
    api_key="wsl-...",
    base_url="https://api.wiserlab.ai/v1"
)

response = client.chat.completions.create(
    model="wiser-core-ultra",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True
)

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

Streaming Native Architecture

Wiser Lab bypasses typical intermediate buffer overhead. By toggling stream: true, the proxy network leverages asynchronous Python streams to safely pipe server-sent chunk records straight back to client runtimes as they compute.

Responses adhere strictly to the standard text/event-stream content protocol, ending execution sequences cleanly with a final data: [DONE] packet.

# Expected Stream Output Format data: {"choices":[{"delta":{"content":"Hi"}}]} data: {"choices":[{"delta":{"content":" there"}}]} data: [DONE]

Error Codes

The gateway leverages explicit HTTP status headers alongside programmatic payload responses to map exceptions gracefully.

Status Code Type Description
401 Unauthorized invalid_api_key The Bearer token passed is inactive, malformed, or missing entirely.
405 Method Not Allowed invalid_http_method The targeted endpoint restricts mutations to POST. Review routing protocols.
502 Bad Gateway node_timeout Node 1 was unable to establish connection parameters back into isolated Node 2 subnets.

Editor & CLI Tool Integration

Wiser Lab acts as a drop-in replacement for standard API endpoints. You can easily configure popular coding assistants and CLI tools to route their requests through our secure gateway by overriding their default environment variables. Below are detailed instructions for configuring OS variables and mapping supported models.

Persistence Notice: For Linux/macOS, add the export commands to your ~/.bashrc or ~/.zshrc file to make them permanent. For Windows, configure them globally via your System Environment Variables GUI.
1. Claude Code

Claude Code natively utilizes Anthropic's SDK mapping. Override the base URL and pass your Wiser Lab key as the Anthropic key.

Linux / macOS (Terminal)
export ANTHROPIC_BASE_URL="https://api.wiserlab.ai" export ANTHROPIC_API_KEY="wsl-..."
Windows (PowerShell)
$env:ANTHROPIC_BASE_URL="https://api.wiserlab.ai" $env:ANTHROPIC_API_KEY="wsl-..."
Model Configuration Mapping: Claude Code requests 'claude-3-5-sonnet' by default. You must explicitly pass a Wiser Lab supported model using the CLI model flag:
claude --model wiser-core-ultra
2. OpenCode

OpenCode leverages OpenAI's routing schema. Ensure you append /v1 to the base URL parameter for full compatibility.

Linux / macOS (Terminal)
export OPENAI_BASE_URL="https://api.wiserlab.ai/v1" export OPENAI_API_KEY="wsl-..."
Windows (PowerShell)
$env:OPENAI_BASE_URL="https://api.wiserlab.ai/v1" $env:OPENAI_API_KEY="wsl-..."
Model Configuration Mapping: OpenCode defaults to GPT-4 endpoints. To remap this, update your OpenCode configuration settings file (usually located at ~/.opencode/config.json) and set your desired default model:
"default_model": "wiser-core-ultra"
3. Codex & Legacy OpenAI Tools

Some older generation tools like Codex utilize OPENAI_API_BASE instead of the modern base URL nomenclature.

Linux / macOS (Terminal)
export OPENAI_API_BASE="https://api.wiserlab.ai/v1" export OPENAI_API_KEY="wsl-..."
Windows (PowerShell)
$env:OPENAI_API_BASE="https://api.wiserlab.ai/v1" $env:OPENAI_API_KEY="wsl-..."