langchain-crynux
Drop-in replacement for langchain-openai ChatOpenAI that lets existing OpenAI-compatible LLM code run on the Crynux network without changes.
Installation
pip install langchain-crynux
Dependencies:
- langchain-openai>=1.0.1
Usage
import os
from langchain_crynux import ChatCrynux
# Option 1: environment variable (same as langchain-openai)
os.environ["OPENAI_API_KEY"] = "your-api-key"
chat = ChatCrynux(
base_url="crynux_base_url",
model="Qwen/Qwen2.5-7B-Instruct",
vram_limit=24,
timeout=60,
# Option 2: pass api_key directly
# api_key="your-api-key",
)
response = chat.invoke("Hello from Crynux.")
print(response.content)
base_urlis the Crynux API endpoint. There is no default.vram_limitis the minimum GPU VRAM (in GB) required for the inference run. Default is 24.
ChatCrynux is a single ChatModel. Call it with invoke / ainvoke / with_structured_output the same way as ChatOpenAI. LangGraph graphs that call ainvoke do not need to change; set the switches on the ChatCrynux constructor.
Responses API and background polling
| Config | Default | Meaning |
|---|---|---|
use_responses_api |
Inherited from ChatOpenAI (None, inferred by the parent class) |
Whether to call /v1/responses |
background |
False |
Whether to send background=true on Responses and poll inside ChatCrynux |
timeout / request_timeout |
Inherited from the parent class | Same parameter, two spellings. background=False: HTTP timeout. background=True: total polling timeout |
http_timeout |
60 when background=True and unset |
Used only when background=True: HTTP timeout for each create / retrieve |
poll_interval |
2.0 |
Used only when background=True: seconds between retrieve calls |
Background example:
from langchain_crynux import ChatCrynux
chat = ChatCrynux(
base_url="crynux_base_url",
model="Qwen/Qwen2.5-7B-Instruct",
use_responses_api=True,
background=True,
timeout=600,
http_timeout=60,
poll_interval=2.0,
)
response = chat.invoke("Hello from Crynux.")
print(response.content)
When background=True, invoke / ainvoke still return a finished AIMessage. ChatCrynux creates the Responses job, polls until completed or failed, and then returns. A failed job or a polling timeout raises an exception.
Synchronous Responses without internal polling:
chat = ChatCrynux(
base_url="crynux_base_url",
model="Qwen/Qwen2.5-7B-Instruct",
use_responses_api=True,
background=False,
)
Structured Output
You can use the with_structured_output method to get structured output from the model.
from typing import Optional
from langchain_crynux import ChatCrynux
from pydantic import BaseModel, Field
class Weather(BaseModel):
"""The weather in a specific location."""
city: str = Field(description="The city to get the weather for")
temperature: float = Field(description="The temperature in celsius")
condition: Optional[str] = Field(description="The weather condition (e.g., sunny, rainy)")
chat = ChatCrynux(
base_url="crynux_base_url",
model="Qwen/Qwen2.5-7B-Instruct",
temperature=0
)
structured_llm = chat.with_structured_output(Weather)
response = structured_llm.invoke("The weather in Tokyo is 25.5 degrees celsius and sunny.")
print(response)
# Weather(city='Tokyo', temperature=25.5, condition='sunny')
The same with_structured_output call works with background=True.
ChatCrynux defaults with_structured_output to method="function_calling". ChatOpenAI defaults to method="json_schema". Many models on Crynux do not support OpenAI json mode, so ChatCrynux uses function calling instead.
Metadata
Release files for langchain-crynux 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_crynux-0.2.0.tar.gz | 17.4 kB | Without provenance | Details for langchain_crynux-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_crynux-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_crynux-0.2.0-py3-none-any.whl |
Total release size: 30.9 kB
Release files / langchain_crynux-0.2.0.tar.gz
| Download URL | langchain_crynux-0.2.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7c40c92e3c51b6aa5d6b906e6fd8d7a6d5bef9374a1530fa4d8f8ff96388040
|
|
BLAKE2b-256 checksum How to use checksums |
998fd24dab3ad3cb66136e3b09c21c81d3dfb32592f51f0da50003e14d2321b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / langchain_crynux-0.2.0-py3-none-any.whl
| Download URL | langchain_crynux-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c50aca923f765891de8c6bccd533bc6847327013cc94fb38d7b4aadb0dad2a1
|
|
BLAKE2b-256 checksum How to use checksums |
0f7d16fe1cbd8f526f2ab087fd9ce71c675e4cf8f06ffc0362882237f4711927
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for langchain-crynux 0.2.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.