Disclosure: I work on InterOdin, the API used in this tutorial. Any OpenAI-compatible provider plugs in the same way.
LangChain pipelines for security work, like log summarisers, alert enrichment or report drafting, break in an annoying way when the model refuses half the inputs. LangChain's OpenAI chat model accepts a custom base URL, so you can put Odin v1 behind an existing chain without touching the rest of it.
Python
pip install langchain-openai
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="odin-v1",
base_url="https://api.interodin.com/v1",
api_key=os.environ["INTERODIN_API_KEY"],
)
print(llm.invoke("Name three Norse gods.").content)
for chunk in llm.stream("Write a haiku about Odin."):
print(chunk.content, end="", flush=True)
Tools and structured output
from langchain_core.tools import tool
from pydantic import BaseModel
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"14°C in {city}"
reply = llm.bind_tools([get_weather]).invoke("What is the weather in Cluj?")
print(reply.tool_calls)
class Person(BaseModel):
name: str
age: int
person = llm.with_structured_output(Person).invoke("Extract the person: Ana is 31.")
print(person)
Using langchain-anthropic instead
ChatAnthropic takes the origin, without /v1:
import os
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(
model="odin-v1",
base_url="https://api.interodin.com",
api_key=os.environ["INTERODIN_API_KEY"],
max_tokens=1024,
)
print(llm.invoke("Name three Norse gods.").content)
JavaScript / TypeScript
npm install @langchain/openai @langchain/core
import { ChatOpenAI } from '@langchain/openai'
const llm = new ChatOpenAI({
model: 'odin-v1',
apiKey: process.env.INTERODIN_API_KEY,
configuration: { baseURL: 'https://api.interodin.com/v1' },
})
const reply = await llm.invoke('Name three Norse gods.')
console.log(reply.content)
for await (const chunk of await llm.stream('Write a haiku about Odin.')) {
process.stdout.write(String(chunk.content))
}
Token usage is reported in response_metadata on each reply.
Limits
- Built-in (hosted) tools are removed from the request; your own tools run.
- Odin v1 is text-only; file inputs in the newest message fail with
400 unsupported_content. - Billing is prepaid credits per token, with no subscription. API prompts and completions are not stored.
Fewer refusals does not mean no rules: the Acceptable Use Policy forbids illegal and harmful uses, so keep it to systems and data you are authorised to work on.
The maintained version of this guide lives in the docs: https://docs.interodin.com/en/integrations/langchain
Top comments (0)