API essentials

Other clients and migration

Configure Anthropic clients, agent harnesses, Vercel AI SDK, and source-included helpers.

Connect a harness

Kendr speaks the OpenAI and Anthropic wire formats, so most agents, IDEs, and SDKs connect by pointing their base URL at https://api.kendr.org and pasting one scoped key. Use model: "kendr-intelligent" for general managed routing with optimized context, kendr-intelligent-direct for general routing with original context, kendr-coder for coding-focused routing with optimized context, or kendr-coder-direct for coding-focused routing with original context. You can also use an exact or account-owned alias returned by GET /v1/models. Unknown aliases fail closed so typos cannot silently change routing or billing. Paste the key you saved at creation in place of <YOUR_KEY> below — full keys are never shown again.

Claude Code — point the Anthropic base URL at Kendr

export ANTHROPIC_BASE_URL=https://api.kendr.org
export ANTHROPIC_AUTH_TOKEN=<YOUR_KEY>
claude
Scope note

Requests stream over SSE in each vendor's wire format, and /v1/messages/count_tokens is available for Anthropic-style token counting. Tools you declare execute on Kendr's servers during generation; harness-local tool execution (for example Claude Code editing files on your machine) is not yet supported, so coding agents work best today for chat, review, and planning workflows.

Use OpenAI, Anthropic, or native HTTPS clients

OpenAI JavaScript client

import OpenAI from "openai";
import crypto from "node:crypto";

const client = new OpenAI({
  apiKey: process.env.KENDR_API_KEY,
  baseURL: "https://api.kendr.org/v1"
});

const response = await client.responses.create({
  model: "kendr-intelligent",
  input: "Plan a safe database migration."
}, {
  headers: { "Idempotency-Key": crypto.randomUUID() }
});

console.log(response.output_text);
console.log(response.kendr_usage);

OpenAI Python client

import os
import uuid
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["KENDR_API_KEY"],
    base_url="https://api.kendr.org/v1",
)

response = client.responses.create(
    model="kendr-intelligent",
    input="Plan a safe database migration.",
    extra_headers={"Idempotency-Key": str(uuid.uuid4())},
)

print(response.output_text)

Anthropic-compatible request

curl https://api.kendr.org/v1/messages \
  -H "Authorization: Bearer $KENDR_API_KEY" \
  -H "Idempotency-Key: messages-001" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kendr-intelligent",
    "max_tokens": 1200,
    "messages": [{"role":"user","content":"Review this plan."}]
  }'

Live streaming

curl -N https://api.kendr.org/v1/chat/completions \
  -H "Authorization: Bearer $KENDR_API_KEY" \
  -H "Idempotency-Key: stream-001" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kendr-intelligent",
    "stream": true,
    "messages": [{"role":"user","content":"Explain the rollout."}]
  }'
Streaming behavior

Exact text routes stream compatible deltas as they arrive. Kendr Routes stream route-selection status first, then stream the selected model's answer and final usage record. Kendr managed routing does not make a second-model verification call.

Migrate an OpenAI client

You do not need to replace the OpenAI Python or JavaScript package. Change the API key, base URL, and model alias; keep the rest of a supported Chat Completions or Responses call intact. Test the exact request fields you use before moving production traffic because Kendr does not claim compatibility with every OpenAI endpoint or every provider-specific extension.

SettingBeforeWith Kendr
API keyYour provider keyKENDR_API_KEY (kndr_live_...)
Base URLProvider defaulthttps://api.kendr.org/v1
ModelProvider model IDkendr-intelligent or an alias from GET /v1/models
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["KENDR_API_KEY"],
    base_url="https://api.kendr.org/v1",
)

result = client.chat.completions.create(
    model="kendr-intelligent",
    messages=[{"role": "user", "content": "Summarize this design."}],
)
print(result.choices[0].message.content)

Supported compatibility routes are GET /v1/models, POST /v1/chat/completions, and POST /v1/responses. Anthropic-format clients can use POST /v1/messages and POST /v1/messages/count_tokens. File uploads, assistants, fine-tuning, realtime sessions, and other unrelated vendor APIs are not implied by “compatible.”

Use Kendr with the Vercel AI SDK

The Vercel AI SDK has an OpenAI-compatible provider adapter. Configure it on your server with the Kendr /v1 base URL and a Kendr key. Do not expose the key through a client component or public environment variable.

npm install ai @ai-sdk/openai-compatible
import { generateText } from "ai";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const kendr = createOpenAICompatible({
  name: "kendr",
  apiKey: process.env.KENDR_API_KEY,
  baseURL: "https://api.kendr.org/v1",
  includeUsage: true,
});

const { text, usage } = await generateText({
  model: kendr.chatModel("kendr-intelligent"),
  prompt: "Give me a three-step rollout plan.",
});

console.log(text, usage);
Compatibility boundary

This example uses the Chat Completions wire format. Kendr-specific kendr_usage, routing, and optimization fields may not be surfaced by every third-party adapter; use raw HTTP or the OpenAI client when your application must persist the complete Kendr receipt.

Source-included helper clients

This repository includes dependency-light helper clients for JavaScript and Python. Use these from the checked-out source or your internal package registry when you want a thinner call surface around the raw HTTP routes, or call the HTTPS endpoints directly from any other runtime. A package manifest is not evidence of a public npm or PyPI release; verify a registry release independently before using an install command.

JavaScript SDK

import { KendrClient } from './sdk/javascript/index.js';

const client = new KendrClient({
  apiKey: process.env.KENDR_API_KEY,
  baseUrl: 'https://api.kendr.org'
});

const response = await client.query({
  surface: 'google_search',
  query: 'best llm observability tools',
  params: { gl: 'us', hl: 'en', page: 1 }
});

console.log(response.data);

Python SDK

from kendr import KendrClient

client = KendrClient(
    api_key='YOUR_KENDR_API_KEY',
    base_url='https://api.kendr.org',
)

response = client.query(
    surface='google_search',
    query='best llm observability tools',
    params={'gl': 'us', 'hl': 'en', 'page': 1},
)

print(response['data'])