SeaLinkSeaLink
/
Back to integrations

Tool setup

LangChain Integration Guide

Point LangChain's ChatOpenAI to SeaLink for chat, tool calling, and RAG with OpenAI-compatible chat models. Python and JS/TS both supported.

AI frameworkOpenAI-compatible

Key Concept

LangChain's ChatOpenAI supports a custom base_url. ChatOpenAI-based chat, streaming, tool-calling, and RAG examples can use the same SeaLink connection settings; exact capability support depends on the model and LangChain version.

Python

Basic Chat
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://test.sealink.io/v1",
api_key="sk-sealink-your-key",
model="gpt-4o-mini",
)
response = llm.invoke("Hello, SeaLink.")
print(response.content)
Streaming
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://test.sealink.io/v1",
api_key="sk-sealink-your-key",
model="gpt-4o-mini",
streaming=True,
)
for chunk in llm.stream("Write a short poem about Singapore."):
print(chunk.content, end="")
Tool Calling
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
@tool
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * b
llm = ChatOpenAI(
base_url="https://test.sealink.io/v1",
api_key="sk-sealink-your-key",
model="gpt-4o-mini",
).bind_tools([multiply])
response = llm.invoke("What is 17 times 42?")
print(response.tool_calls)

JavaScript / TypeScript

Basic Chat
import { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({
configuration: {
baseURL: "https://test.sealink.io/v1",
apiKey: process.env.SEALINK_API_KEY,
},
model: "gpt-4o-mini",
});
const response = await llm.invoke("Hello, SeaLink.");
console.log(response.content);

Installation

Python install

pip install langchain langchain-openai

The langchain-openai package includes ChatOpenAI with built-in base_url support.

JS/TS install

npm install @langchain/openai @langchain/core

Requires Node.js ≥ 18.

Common Issues

ImportError: No module named 'langchain_openai'

You need the langchain-openai package. Run: pip install langchain-openai. Note: pip install langchain alone doesn't include OpenAI integration.

Empty or malformed model output

Verify the model ID is correct. Some models need additional LangChain configuration; test with a general chat model first to confirm connectivity.

Streaming doesn't work

In Python, streaming=True only affects .stream() — .invoke() won't stream. In JS/TS, ensure streaming: true is set.