Default WorkspaceGuides
429 fallback, coding agents & gateway comparisons

Use SentioGate with LangChain (Python and JavaScript)

· Published · Facts and limits are dated; check the linked sources.

SentioGate exposes an OpenAI-compatible Chat Completions API, so LangChain talks to it through its standard ChatOpenAI class. You change two settings, the base URL and the API key, and keep the rest of your chains, agents and tools as they are.

As of 2026-10-30, checked against LangChain's ChatOpenAI docs for Python and for JavaScript.

What you need

  • A SentioGate API key (sg_live_...), created in the Vault.
  • The base URL https://api.sentiogate.dev/v1.
  • A model name. auto lets SentioGate pick a model for each request. On the free community pool (a shared community tier for trying SentioGate), auto is the only model you can use. With your own provider keys in the Vault you can also pin a model as provider/model, for example openai/gpt-4o-mini.

Keep the key in an environment variable, for example SENTIOGATE_API_KEY, rather than in your code.

Python

Install the integration package:

pip install -U langchain-openai

Then create the model with SentioGate's base URL and key:

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="auto",
    base_url="https://api.sentiogate.dev/v1",
    api_key=os.environ["SENTIOGATE_API_KEY"],
)

reply = llm.invoke("Summarize what an API gateway does in one sentence.")
print(reply.content)

ChatOpenAI reads the base URL from the base_url argument first, then from the OPENAI_API_BASE and OPENAI_BASE_URL environment variables, so you can also configure it without touching code.

JavaScript and TypeScript

Install the packages:

npm install @langchain/openai @langchain/core

In JavaScript the base URL goes in the configuration object:

import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "auto",
  apiKey: process.env.SENTIOGATE_API_KEY,
  configuration: {
    baseURL: "https://api.sentiogate.dev/v1",
  },
});

const reply = await llm.invoke("Summarize what an API gateway does in one sentence.");
console.log(reply.content);

Streaming

Streaming works the same as with OpenAI:

for chunk in llm.stream("Write a haiku about latency."):
    print(chunk.content, end="", flush=True)
for await (const chunk of await llm.stream("Write a haiku about latency.")) {
  process.stdout.write(String(chunk.content));
}

Tools and agents

Tool calling goes through the standard Chat Completions tools field, so bind_tools / bindTools and LangChain agents work unchanged. If you pin a model, pick one that supports tool calling.

from langchain_core.tools import tool

@tool
def get_order_status(order_id: str) -> str:
    """Look up the status of an order."""
    return "shipped"

llm_with_tools = llm.bind_tools([get_order_status])
msg = llm_with_tools.invoke("Where is order 1234?")
print(msg.tool_calls)

Group requests into a session

Send the same session id on every request of a conversation or agent run. If you turn on the Langfuse export, those requests then appear as one session in your Langfuse project. Send it as the X-Session-ID header:

llm = ChatOpenAI(
    model="auto",
    base_url="https://api.sentiogate.dev/v1",
    api_key=os.environ["SENTIOGATE_API_KEY"],
    default_headers={"X-Session-ID": "support-ticket-1234"},
)
const llm = new ChatOpenAI({
  model: "auto",
  apiKey: process.env.SENTIOGATE_API_KEY,
  configuration: {
    baseURL: "https://api.sentiogate.dev/v1",
    defaultHeaders: { "X-Session-ID": "support-ticket-1234" },
  },
});

Troubleshooting

  • 401 invalid_api_key: the key is missing or wrong. LangChain falls back to OPENAI_API_KEY if you do not pass api_key / apiKey, so check which key is actually sent.
  • A model is rejected on the free tier: the free community pool only accepts model: "auto". Add your own provider key in the Vault to pin models.
  • 429 rate_limited: you went over the request limit for your plan (600 requests per 5 hours per user on the free community pool). Wait for the Retry-After time.
  • Requests go to api.openai.com: the base URL was not picked up. Pass base_url (Python) or configuration.baseURL (JavaScript) explicitly.

Sources

All accessed 2026-10-30.