Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_thalam-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_thalam-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file langchain_thalam-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_thalam-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for langchain_thalam-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ffb8516fe04f53e749ac0b1be4cafab0abfbec68cb19e12b9b60ed0408ca251c
MD5 0f476399e0074335e8018a4ccaf5140e
BLAKE2b-256 c210ae9fbd846ad41b1ddcff8c2297df5c9650f6e399f161f9863fcabf6613ca

See more details on using hashes here.

File details

Details for the file langchain_thalam-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_thalam-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb326f9d66408e96a8ea8b6a30e6c9c98ea6556d8306692bfcbe13e6eb809e9
MD5 c17730f89117a01672d10840e6f6a306
BLAKE2b-256 96fdd9e71664dd60d19c47a8e4914fb6f5746fd1930c402f464b3ba11fddd7e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page