Responses API
Crynux Network supports the OpenAI Responses API. Compared with a single chat/completions request that must stay open until the model finishes, Responses lets you create a job, disconnect immediately, and poll for the result later.
This is useful when your application needs to run long tasks, recover after offline or reconnect periods, or submit a large number of tasks without holding many long-lived HTTP connections.
Crynux supports:
POST /v1/responsesto create a responseGET /v1/responses/{response_id}to retrieve status and resultbackground=truefor asynchronous execution with client-side pollingprevious_response_idto continue a conversation from a completed response
Using the OpenAI SDK with Background Polling
Set background=true when creating a response. The create call returns quickly with a response ID and a non-terminal status such as queued or in_progress. Keep calling retrieve until the status becomes completed or failed.
import time
from openai import OpenAI
client = OpenAI(
base_url="https://api.crynux-as.xyz/v1/llm",
api_key="your-api-key",
timeout=60,
max_retries=1,
)
response = client.responses.create(
model="Qwen/Qwen2.5-7B-Instruct",
input="Write a short plan for building a todo app.",
background=True,
extra_body={
"vram_limit": 24,
},
)
print(f"created: id={response.id}, status={response.status}")
while response.status in ("queued", "in_progress"):
time.sleep(2)
response = client.responses.retrieve(response.id)
print(f"polling: status={response.status}")
if response.status == "completed":
print(response.output_text)
else:
print(f"failed: {response.error}")Using langchain-crynux
langchain-crynux wraps the Responses background flow inside a normal LangChain invoke / ainvoke call. With background=True, ChatCrynux creates the Responses job, polls until it finishes, and returns a completed AIMessage.
Installation
Background example
Parameter
Meaning when background=True
use_responses_api
Must be True (or omitted; ChatCrynux enables it automatically when background=True)
background
Sends background=true and polls inside ChatCrynux
timeout / request_timeout
Total time allowed for the whole poll loop
http_timeout
Timeout for each individual create / retrieve HTTP request
poll_interval
Seconds to wait between retrieve calls
Streaming is not supported when background=True.
If you only need Responses without background polling, you can set use_responses_api=True and background=False, or use langchain-openai with use_responses_api=True.
For general LangChain and LangGraph setup, see:
Integration with LangChain & LangGraphContinuing a Conversation with previous_response_id
After a Responses job completes, you can start a new Responses call with previous_response_id set to the previous response's id. Crynux reconstructs the prior conversation history on the server, so the new request only needs to send the new user input.
instructions on a new call apply only to that call. They are not inherited from the previous response.
Last updated