LangChain
LangChain’s ChatOpenAI takes a base URL and key, so it talks to OpenPike’s chat completions endpoint with any model there.
Python (langchain-openai) |
TypeScript (@langchain/openai) |
|
|---|---|---|
| Base URL | base_url="https://api.openpike.dev/v1" |
configuration: { baseURL: "https://api.openpike.dev/v1" } |
| Key | api_key= a virtual key |
apiKey: a virtual key |
| Tags | default_headers={"x-openpike-tags": ...} |
configuration: { defaultHeaders: {...} } |
| Model | model="deepseek/deepseek-flash" |
model: "deepseek/deepseek-flash" |
Install
Section titled “Install”pip install langchain-openai # Pythonnpm install @langchain/openai # TypeScriptExample
Section titled “Example”import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI( model="deepseek/deepseek-flash", base_url="https://api.openpike.dev/v1", api_key=os.environ["OPENPIKE_API_KEY"], default_headers={"x-openpike-tags": "agent=docs-example,env=dev"},)
reply = llm.invoke("Name one river in Europe.")print(reply.content)import { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({ model: "deepseek/deepseek-flash", apiKey: process.env.OPENPIKE_API_KEY, configuration: { baseURL: "https://api.openpike.dev/v1", defaultHeaders: { "x-openpike-tags": "agent=docs-example,env=dev" }, },});
const reply = await llm.invoke("Name one river in Europe.");console.log(reply.content);- Stay on Chat Completions for most providers. LangChain’s docs say
ChatOpenAIswitches to OpenAI’s Responses API when you use a Responses-only feature or setuse_responses_api=True. OpenPike serves the Responses API only for providers that serve it themselves (OpenAI, xAI, Groq and OpenRouter; it does not translate formats), so leave those off for DeepSeek, Gemini and the other providers. - Claude models need the Anthropic format; they are not available through
ChatOpenAI. Use an OpenAI-format model, or the Anthropic SDK directly. - A run ID per task. To cap one agent run with a run budget, create the model per task with
x-openpike-runindefault_headers(TypeScript:configuration.defaultHeaders). Keep the SDK’s default retries: a blocked request never reaches the provider, and onrun_limit_exceededthe task should stop and tell the user. - Agents, chains and tools built on
ChatOpenAIwork unchanged, and every call they make shows in OpenPike’s Logs.
Example
Section titled “Example”Runnable copies of this setup, with a .env.example, are in the OpenPike examples repo: Python and TypeScript.