All integrations

LangChain integration

Use DeepSeek in LangChain Through Tokuse and ChatOpenAI

LangChain can use an OpenAI-compatible chat model when the provider follows the chat completions contract. ChatOpenAI keeps the integration small and lets you change the model alias later.

Settings

Class
ChatOpenAI
Base URL
https://tokuse.com/v1
Model
deepseek-flash

Setup steps

  1. Install langchain-openai and the OpenAI SDK.
  2. Keep TOKUSE_API_KEY in the server environment.
  3. Configure ChatOpenAI with base_url https://tokuse.com/v1.
  4. Select a model currently available in your Tokuse account.
  5. Add timeout, retry, and evaluation logic before production rollout.

Configuration

import os

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek-flash",
    api_key=os.environ["TOKUSE_API_KEY"],
    base_url="https://tokuse.com/v1",
    timeout=30,
    max_retries=2,
)

result = llm.invoke("Return a JSON object with a one-line release summary.")
print(result.content)

Before production use

  • Keep the Tokuse key on the server or in the tool's secret store.
  • Use the base URL without appending /chat/completions.
  • Verify the model alias in the current Tokuse catalog.
  • Test errors, timeout behavior, and cost with a small workload first.

Related tools

Open Tokuse