Skip to main content

langchain-thalam

LangChain integration for thalam. — one OpenAI-compatible endpoint for every leading AI model.

Built in the UAE. Text, image, and video models from a single endpoint, with per-key spend caps and audit logs as a built-in governance layer.

  • One endpoint — DeepSeek, Qwen, Kimi, GLM, MiniMax, Claude, GPT, Llama, Grok, Mistral and more
  • Drop-in LangChain compatibility — every LangChain feature (streaming, tools, structured output, async) works unchanged
  • Pay per token — no subscription, no minimums
  • AED or USD invoicing on Enterprise contracts

Install

pip install langchain-thalam

Sign up at thalam.ai — no card required: new accounts get $1 in starter credit to use right away, then add a card to top up.

Quickstart

import os
from langchain_thalam import ChatThalam

os.environ["THALAM_API_KEY"] = "tl-..."

llm = ChatThalam(model="deepseek/deepseek-v3.2", temperature=0)

response = llm.invoke("Explain quantum entanglement in 2 sentences.")
print(response.content)

Or pass the key explicitly:

from langchain_thalam import ChatThalam

llm = ChatThalam(
    model="qwen/qwen3-max",
    api_key="tl-...",
)

Streaming

from langchain_thalam import ChatThalam

llm = ChatThalam(model="deepseek/deepseek-v3.2")

for chunk in llm.stream("Write a haiku about Dubai."):
    print(chunk.content, end="", flush=True)

Tool calling

from langchain_thalam import ChatThalam
from langchain_core.tools import tool

@tool
def get_weather(city: str) -> dict:
    """Get the weather in a city."""
    return {"temp": 32, "unit": "C", "city": city}

llm = ChatThalam(model="deepseek/deepseek-v4-pro")
llm_with_tools = llm.bind_tools([get_weather])

response = llm_with_tools.invoke("What's the weather in Dubai?")
print(response.tool_calls)

Structured outputs

from langchain_thalam import ChatThalam
from pydantic import BaseModel, Field

class BlogMetadata(BaseModel):
    title: str = Field(description="The post title")
    tags: list[str] = Field(description="3-5 relevant tags")

llm = ChatThalam(model="deepseek/deepseek-v3.2")
structured_llm = llm.with_structured_output(BlogMetadata)

result = structured_llm.invoke("Generate metadata for a post about MENA fintech.")
print(result.title, result.tags)

Async

import asyncio
from langchain_thalam import ChatThalam

async def main():
    llm = ChatThalam(model="deepseek/deepseek-v3.2")
    result = await llm.ainvoke("Hi")
    print(result.content)

asyncio.run(main())

In a LangChain chain

from langchain_thalam import ChatThalam
from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a senior MENA fintech analyst. Respond concisely."),
    ("user", "{question}"),
])

llm = ChatThalam(model="deepseek/deepseek-v3.2")
chain = prompt | llm

result = chain.invoke({"question": "Top 3 fintech trends in the UAE in 2026?"})
print(result.content)

Available models

The full live catalog is at thalam.ai/models or via:

import os, requests
r = requests.get(
    "https://api.thalam.ai/v1/models",
    headers={"Authorization": f"Bearer {os.environ['THALAM_API_KEY']}"},
)
for m in r.json()["data"]:
    print(m["id"], "-", m["display_name"], "-", m["category"])

Common text-model IDs:

ID Notes
deepseek/deepseek-v4-pro Flagship reasoning, 1M context
deepseek/deepseek-v4-flash Fast, low-cost
deepseek/deepseek-v3.2 Strong general intelligence
deepseek/deepseek-r1-0528 Open reasoning
qwen/qwen3-max Frontier multilingual + Arabic
qwen/qwen3.5-397b-a17b Large MoE, top open quality
qwen/qwen3-coder-480b-a35b-instruct Coding flagship
zhipu/glm-5.1 Multimodal-capable
moonshotai/kimi-k2-thinking Long-context reasoning
anthropic/claude-opus-4.8 Flagship reasoning (via gateway)
anthropic/claude-opus-4.7 Premium reasoning (via gateway)
anthropic/claude-sonnet-4.6 Balanced (via gateway)
openai/gpt-5.4 OpenAI flagship (via gateway)
xai/grok-4 xAI flagship
meta-llama/llama-3.3-70b-instruct Open Llama
meta-llama/llama-4-maverick-17b-128e-instruct-fp8 Llama 4 flagship

Configuration

from langchain_thalam import ChatThalam

llm = ChatThalam(
    model="deepseek/deepseek-v3.2",
    api_key="tl-...",                              # default: env THALAM_API_KEY
    base_url="https://api.thalam.ai/v1",            # default
    temperature=0.7,
    max_tokens=512,
    timeout=60,
    max_retries=2,
)

Every keyword argument that langchain_openai.ChatOpenAI accepts is supported.

Links

License

Apache-2.0

Metadata

Release files for langchain-thalam 0.1.0

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-thalam 0.1.0
File Size Uploaded Provenance Actions
langchain_thalam-0.1.0.tar.gz 6.3 kB Without provenance Details for langchain_thalam-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-thalam 0.1.0
File Interpreter ABI Platform Actions
langchain_thalam-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_thalam-0.1.0-py3-none-any.whl

Total release size: 13.3 kB

Release files / langchain_thalam-0.1.0.tar.gz

Download URL langchain_thalam-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ffb8516fe04f53e749ac0b1be4cafab0abfbec68cb19e12b9b60ed0408ca251c
BLAKE2b-256 checksum
How to use checksums
c210ae9fbd846ad41b1ddcff8c2297df5c9650f6e399f161f9863fcabf6613ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / langchain_thalam-0.1.0-py3-none-any.whl

Download URL langchain_thalam-0.1.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cb326f9d66408e96a8ea8b6a30e6c9c98ea6556d8306692bfcbe13e6eb809e9
BLAKE2b-256 checksum
How to use checksums
96fdd9e71664dd60d19c47a8e4914fb6f5746fd1930c402f464b3ba11fddd7e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for langchain-thalam 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.0 This release

2 release files No 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