All integrations
🐍

OpenAI SDK

Official OpenAI Python / TypeScript SDK pointed at clawfeeder

Protocol: OpenAILast verified 2026-05-19

The OpenAI Python and TypeScript SDKs both accept a base_url parameter at client construction time. Setting it once routes every chat / embedding / image call to clawfeeder; no other code change needed.

Prerequisites

Python 3.8+ or Node 18+, the openai package installed, and a clawfeeder API key.

Steps

1Install the SDK

Both ecosystems publish under the official 'openai' namespace.

pip install openai
# or:
npm install openai

2Python: construct the client

Pass base_url and api_key explicitly so the SDK doesn't fall back to OpenAI defaults.

from openai import OpenAI

client = OpenAI(
    base_url="https://clawfeeder.ai/v1",
    api_key="cf-sk-***your_key***",
)

resp = client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Hello!"}],
    max_tokens=100,
)
print(resp.choices[0].message.content)

3TypeScript: construct the client

Identical pattern in the TS SDK. Use top-level await or wrap in an async fn.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://clawfeeder.ai/v1",
  apiKey: "cf-sk-***your_key***",
});

const resp = await client.chat.completions.create({
  model: "gpt-5.2",
  messages: [{ role: "user", content: "Hello!" }],
  max_tokens: 100,
});
console.log(resp.choices[0].message.content);

4Streaming

Add stream=true (Python) / stream: true (TS). clawfeeder transparently passes SSE chunks; the SDK iterates them as deltas.

stream = client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Write a haiku"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Verify

Run a one-liner from a Python shell after exporting your key.

from openai import OpenAI; c = OpenAI(base_url="https://clawfeeder.ai/v1", api_key="cf-sk-***"); print(c.chat.completions.create(model="gpt-5.2", messages=[{"role":"user","content":"reply READY"}], max_tokens=10).choices[0].message.content)

Expected response includes: READY

FAQ

Can I use Anthropic / Claude models through the OpenAI SDK?

Yes. clawfeeder accepts claude-* model IDs at /v1/chat/completions and translates internally. You don't need the Anthropic SDK unless you want Anthropic-specific features (e.g. structured cache_control hints).

Function calling / tool use — supported?

Yes for all models that natively support it (gpt-5.x, claude-* family). Use the standard OpenAI 'tools' parameter; clawfeeder passes it through unchanged.

Why is response_format JSON mode flaky?

JSON mode reliability is upstream-model dependent. gpt-5.x has best JSON mode; Claude family responds best to explicit instructions like 'Reply with valid JSON only'. clawfeeder forwards the flag unchanged.

Can I use organization / project headers?

clawfeeder ignores OpenAI organization and project headers — your user account on clawfeeder is the billing entity. Set them or leave them off; either works.

Don't have an API key yet?

Sign up for 300 free credits, 7-day trial, all models

Get started free →
OpenAI SDK × clawfeeder.ai — Integration Guide