Launch preview Service availability and integrations are being verified. View readiness

SDKs and curl

Python, JavaScript and Anthropic SDK examples with the correct Redline base URLs.

Community examples. Syntax follows the client interfaces; live Redline compatibility is subject to launch verification.

OpenAI Python SDK

Set the base URL with /v1. Use an environment variable for your key.

Python
# Install: pip install openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["REDLINE_API_KEY"],
    base_url="https://api.redline-api.duckdns.org/v1",
)
response = client.chat.completions.create(
    model="redline-core",
    messages=[{"role": "user", "content": "Draft a code review checklist."}],
    max_tokens=256,
)
print(response.choices[0].message.content)

OpenAI JavaScript SDK

Run on the server or locally, never in a browser bundle containing a secret.

JavaScript
// Install: npm install openai
// Save as example.mjs, then run: node example.mjs
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.REDLINE_API_KEY,
  baseURL: "https://api.redline-api.duckdns.org/v1",
});
const response = await client.chat.completions.create({
  model: "redline-core",
  messages: [{ role: "user", content: "Draft a code review checklist." }],
  max_tokens: 256,
});
console.log(response.choices[0].message.content);

Anthropic Python SDK

Use the origin without /v1. Set ANTHROPIC_AUTH_TOKEN to your Redline key.

Python
# Install: pip install anthropic
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=None,
    auth_token=os.environ["ANTHROPIC_AUTH_TOKEN"],
    base_url="https://api.redline-api.duckdns.org",  # No /v1 here
)
message = client.messages.create(
    model="redline-core",
    max_tokens=256,
    messages=[{"role": "user", "content": "Draft a code review checklist."}],
)
print(message.content)

curl

This example is written for Bash/zsh and makes a billable request.

curl
curl "https://api.redline-api.duckdns.org/v1/chat/completions" \
  -H "Authorization: Bearer $REDLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "redline-core",
    "messages": [{
      "role": "user",
      "content": "Draft a checklist for an authorised code review."
    }],
    "max_tokens": 256
  }'