Skip to main content
LangChain is a framework for LLM apps — chains, agents, RAG. Since RuAPI is OpenAI-compatible, connecting comes down to the ChatOpenAI class with a changed base_url — no separate integration needed.

Prerequisites

1

RuAPI account and API key

Console → Tokens → create an sk-... key. The balance tops up in USDT — see Top-up.

Python

pip install langchain langchain-openai
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="claude-opus-4-8",                  # exact name on the pricing page
    api_key="sk-YOUR_KEY",
    base_url="https://www.ruapi.ai/v1",  # with /v1
)

print(llm.invoke("Hi! Answer in one sentence.").content)
From here llm drops into any chain, agent or LCEL construct like a regular model.

JavaScript / TypeScript

npm install @langchain/openai @langchain/core
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "claude-opus-4-8",
  apiKey: "sk-YOUR_KEY",
  configuration: { baseURL: "https://www.ruapi.ai/v1" },
});

const res = await llm.invoke("Hi! Answer in one sentence.");
console.log(res.content);
To switch models, change the model field. The same key reaches Claude, GPT, Gemini, DeepSeek and more.

Embeddings (RAG)

from langchain_openai import OpenAIEmbeddings

embeddings = OpenAIEmbeddings(
    model="text-embedding-3-small",       # or another embedding model from the catalog
    api_key="sk-YOUR_KEY",
    base_url="https://www.ruapi.ai/v1",
)

Troubleshooting

api_key must be a RuAPI token (sk-...). Check for stray spaces.
The name in model must match RuAPI verbatim — see the pricing page.
No. Claude is called through ChatOpenAI on the same base_url — just put the Claude model ID in the model field.