Skip to main content

langchain-optiq

LangChain chat model for OptiQ Cloud. ChatOptiQ is a ChatOpenAI-style model with the OptiQ Cloud base URL, key and model ids set, plus reasoning_effort passed through to the API.

Installation

pip install -U langchain-optiq
export OPTIQ_API_KEY="sk-optiq-cloud-..."

Create a key on the OptiQ Cloud dashboard. OPTIQ_CLOUD_API_KEY, the name used in the OptiQ docs, is read when OPTIQ_API_KEY is not set.

Usage

from langchain_optiq import ChatOptiQ

llm = ChatOptiQ(model="deepseek-v4.1-flash", reasoning_effort="low")
print(llm.invoke("Name three uses of a hash map.").content)

Streaming, async, tool calling and structured output work as they do with ChatOpenAI:

from pydantic import BaseModel


class City(BaseModel):
    name: str
    country: str


llm = ChatOptiQ(model="glm-5.3-flash", reasoning_effort="minimal")
llm.with_structured_output(City).invoke("The capital of Japan")

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

Models

model context reasoning_effort values
glm-5.3-flash (default) 1,048,576 minimal, low, medium, high, xhigh
glm-5.3 1,048,576 minimal, low, medium, high, xhigh
deepseek-v4.1-flash 1,040,000 none, minimal, low, medium, high, xhigh
minimax-m3.1-flash 1,000,000 minimal, low, medium, high, xhigh

The current list, with prices, is at GET https://cloud.mlx-optiq.com/api/v1/models (no key needed). Any model id from that list can be passed as model.

Reasoning

Every model thinks before it answers, and thinking is billed as output. With no reasoning_effort, a model thinks fully. minimal or low thinks least on the models that always think. Only deepseek-v4.1-flash takes none, which turns thinking off. A value the model does not take comes back as a 400 before the model runs, so nothing is charged. The measured effect of each value is in the API reference.

When the API returns the thinking text, it is kept in message.additional_kwargs["reasoning_content"].

Configuration

argument environment variable default
api_key OPTIQ_API_KEY, then OPTIQ_CLOUD_API_KEY (required)
base_url OPTIQ_API_BASE https://cloud.mlx-optiq.com/api/v1
model glm-5.3-flash

Other ChatOpenAI arguments such as max_tokens, temperature, timeout, max_retries and default_headers are passed through. Sending the same x-session-id header on every call of one task keeps that task's prompt cache:

llm = ChatOptiQ(default_headers={"x-session-id": "task-42"})

Development

uv sync --all-groups
make test               # unit tests, network disabled
make integration_tests  # live API, needs OPTIQ_API_KEY
make lint

License

MIT

Metadata

Release files for langchain-optiq 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-optiq 0.1.0
File Size Uploaded Provenance Actions
langchain_optiq-0.1.0.tar.gz 7.1 kB Without provenance Details for langchain_optiq-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 13.8 kB

Release files / langchain_optiq-0.1.0.tar.gz

Download URL langchain_optiq-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
83486abbdcf267b751cd982f1fa995d12bcbeb1de391f3e849b3886dd9451302
BLAKE2b-256 checksum
How to use checksums
ee5e57525d0b2a6e0a5b71b753923430a5a2ada5e337e4f1548fa450a32d7bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

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

Download URL langchain_optiq-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
299d76edfbedcd72b32b60988fdd7803e87d04968117e1577fba99884f642c6e
BLAKE2b-256 checksum
How to use checksums
9f9edeb76919b8b5d4562620f500b9daf6c9080b065a495c9d72cecbd07e9a64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for langchain-optiq 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