For the complete documentation index, see llms.txt. This page is also available as Markdown.

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/responses to create a response

  • GET /v1/responses/{response_id} to retrieve status and result

  • background=true for asynchronous execution with client-side polling

  • previous_response_id to continue a conversation from a completed response

The code examples below use the official OpenAI SDK. The only required change is pointing the client base_url at your Crynux API endpoint, the same way as in the parent guide.

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 & LangGraph

Continuing 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.

previous_response_id only accepts a successfully completed Responses job that is still available for lookup. Failed or unfinished responses cannot be used as the previous response. Each new call stores the fully expanded history, so later turns do not depend on older ancestor responses remaining available.

instructions on a new call apply only to that call. They are not inherited from the previous response.

Last updated