Skip to content

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"
Terminal window
pip install langchain-openai # Python
npm install @langchain/openai # TypeScript
chat.py
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)
  • Stay on Chat Completions for most providers. LangChain’s docs say ChatOpenAI switches to OpenAI’s Responses API when you use a Responses-only feature or set use_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-run in default_headers (TypeScript: configuration.defaultHeaders). Keep the SDK’s default retries: a blocked request never reaches the provider, and on run_limit_exceeded the task should stop and tell the user.
  • Agents, chains and tools built on ChatOpenAI work unchanged, and every call they make shows in OpenPike’s Logs.

Runnable copies of this setup, with a .env.example, are in the OpenPike examples repo: Python and TypeScript.