Skip to main content

langchain-topxai

LangChain chat model for TopxAI, an API gateway that serves Claude, GPT, Grok, GLM, Kimi and DeepSeek models through one OpenAI-compatible endpoint at fixed USD prices per route.

Installation

pip install -U langchain-topxai

Create a key at https://ai.topxea.com/keys and set it:

export TOPXAI_API_KEY="your-api-key"

Chat models

from langchain_topxai import ChatTopxAI

model = ChatTopxAI(model="kimi-k3.1-pro")
model.invoke("Sing a ballad of LangChain.")

model takes any text model id from https://ai.topxea.com/pricing, for example claude-sonnet-5-5, gpt-6.1-sol, grok-4.7, kimi-k3.1-pro or deepseek-flash-Abliterated. ChatTopxAI builds on langchain-openai's BaseChatOpenAI and always calls the Chat Completions API: streaming, async calls, tool calling, structured output and token usage work as they do there. For TopxAI's Responses API, use ChatOpenAI from langchain-openai with base_url="https://ai.topxea.com/v1" and use_responses_api=True.

When a model returns reasoning text in the Chat Completions reasoning_content field, ChatTopxAI puts it in additional_kwargs["reasoning_content"], also when streaming:

msg = ChatTopxAI(model="deepseek-flash-Abliterated").invoke("What is 17 * 3?")
msg.additional_kwargs.get("reasoning_content")

Kimi K3.1 Pro uses always-on reasoning; omit sampling controls such as temperature. See its model guide for supported parameters.

with_structured_output uses JSON Schema by default (method="json_schema", as in ChatOpenAI). Keep the default for the Claude models (claude-sonnet-5-5, claude-opus-5-5, claude-fable-5-1): they do not accept a forced tool call, so method="function_calling" fails for them.

The catalogue was checked on 2026-10-25. kimi-k3, deepseek-flash and deepseek-v4-pro are retired and are rejected; they are not aliases. GLM-5.3-Abliterated and deepseek-flash-Abliterated are private deployments. Check the live catalogue and the model page for current capabilities and prices; support varies by model.

Configuration

Argument Environment variable Default
api_key TOPXAI_API_KEY none; required. OPENAI_API_KEY is never read.
base_url TOPXAI_API_BASE https://ai.topxea.com/v1

Development

make tests              # unit tests, no network
make integration_tests  # LangChain standard integration tests, needs TOPXAI_API_KEY
make lint type

MIT licensed. Maintained by TopXEA, the operator of TopxAI.

Metadata

Release files for langchain-topxai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-topxai 0.1.1
File Size Uploaded Provenance
langchain_topxai-0.1.1.tar.gz 10.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-topxai 0.1.1
File Interpreter ABI Platform
langchain_topxai-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / langchain_topxai-0.1.1.tar.gz

Download URL langchain_topxai-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f64175b5d5f8c7a682ba29ebd98a3c97f9ff3ceeeac35a11e9c860bfe35d5c6a
BLAKE2b-256 checksum
How to use checksums
a13c6db5325e8d3da01fd78bb636b01af61776d7609f7413c9e9d168dd2cd115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / langchain_topxai-0.1.1-py3-none-any.whl

Download URL langchain_topxai-0.1.1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7453b651dd99ba521e906235e421080766bb184ddf6be824b5dcbc17d6c6255
BLAKE2b-256 checksum
How to use checksums
aa697c496db7b926f20f3d62d0afffc9ce45edc1da1e2c0df87cdb7fb705972c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for langchain-topxai 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_topxai-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page