For the complete documentation index, see llms.txt. This page is also available as Markdown.

LangChain

Use TensorX models with LangChain, the popular framework for building LLM-powered applications.

Installation

pip install -U langchain-openai

Quick Start

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="z-ai/glm-5.1",
    base_url="https://api.tensorx.ai/v1",
    api_key="your-tensorx-api-key",
)

response = llm.invoke("Hello, how are you?")
print(response.content)

Configuration

LangChain's ChatOpenAI class supports OpenAI-compatible APIs through the base_url parameter.

Parameter
Value

base_url

https://api.tensorx.ai/v1

api_key

Your TensorX API key

model

Any TensorX model ID

Examples

Basic Chat

Streaming

Tool Calling

Structured Output

Async Usage

Available Models

Model
ID
Best For

GLM-5.1 ⭐

z-ai/glm-5.1

Coding, reasoning, functions

MiniMax-M2.5

minimax/minimax-m2.5

Reasoning, functions

Kimi-K2.5

moonshotai/kimi-k2.5

Vision, functions, long context

MiniMax-M2

minimax/minimax-m2

Coding, fast responses

Tips

  • Use z-ai/glm-5.1 for applications that require tool/function calling

  • Use minimax/minimax-m2 for reasoning tasks and long conversations

  • Set temperature=0 for deterministic outputs

Resources

Last updated

Was this helpful?