Docs menu

LangChain

Both wires, Python and JavaScript. State: verified against the integration packages' source.

Install#

bash
pip install langchain-openai langchain-anthropic          # Python
npm install @langchain/openai @langchain/anthropic          # JavaScript

OpenAI wire#

Base URL https://sator-api.princep.org/v1.

Python — OpenAI wire#

ChatOpenAI decides per model id whether to call /v1/chat/completions or /v1/responses; Sator serves both, so either choice works and use_responses_api can be left alone. (Do not enable LangChain's stateful Responses features — previous_response_id is refused; see Responses.)

python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-v4-flash",
    base_url="https://sator-api.princep.org/v1",
    api_key="sk-sator-v1-...",
)
print(llm.invoke("Say hi").content)

JavaScript — OpenAI wire#

ts
import { ChatOpenAI } from '@langchain/openai';

const llm = new ChatOpenAI({
  model: 'deepseek-v4-flash',
  apiKey: process.env.SATOR_API_KEY,
  configuration: { baseURL: 'https://sator-api.princep.org/v1' },
});
console.log((await llm.invoke('Say hi')).content);

Anthropic wire#

Base URL https://sator-api.princep.org — no /v1.

Python — Anthropic wire#

python
from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
    model="deepseek-v4-flash",
    base_url="https://sator-api.princep.org",
    api_key="sk-sator-v1-...",
    max_tokens=256,
)
print(llm.invoke("Say hi").content)

JavaScript — Anthropic wire#

ts
import { ChatAnthropic } from '@langchain/anthropic';

const llm = new ChatAnthropic({
  model: 'deepseek-v4-flash',
  apiKey: process.env.SATOR_API_KEY,
  anthropicApiUrl: 'https://sator-api.princep.org',
  maxTokens: 256,
});
console.log((await llm.invoke('Say hi')).content);

Verify#

Each sample prints a short reply; the request appears in your dashboard. Tool binding (bind_tools / bindTools) and structured output work on both wires — see Tool calling.

Troubleshooting#

  • 404 on the OpenAI wirebase_url is missing its /v1.
  • 404 on the Anthropic wire — the base URL has a /v1 on it. Remove it.
  • Token countingChatAnthropic.get_num_tokens_from_messages calls count_tokens, which Sator serves as an estimate rather than the model's own tokenizer. See Messages.