Skip to content

opengradient / client / twins

Package opengradient.client.twins ​

Digital twins chat via OpenGradient verifiable inference.

Classes ​

Twins ​

Digital twins chat namespace.

Provides access to digital twin conversations backed by OpenGradient verifiable inference. Browse available twins at https://twin.fun.

Constructor ​

python
def __init__(api_key: str)

Methods ​


chat() ​

python
def chat(
    self,
    twin_id: str,
    model: `TEE_LLM`,
    messages: List[Dict],
    temperature: Optional[float] = None,
    max_tokens: Optional[int] = None
) ‑> `TextGenerationOutput`

Chat with a digital twin.

Arguments

  • twin_id: The unique identifier of the digital twin.
  • model: The model to use for inference (e.g., TEE_LLM.GROK_4_1_FAST_NON_REASONING).
  • messages: The conversation messages to send.
  • temperature: Sampling temperature. Optional.
  • max_tokens: Maximum number of tokens for the response. Optional.

Returns

TextGenerationOutput: Generated text results including chat_output and finish_reason.

TextGenerationOutput fields:

  • data_settlement_transaction_hash: Blockchain transaction hash for the data settlement transaction. None when the provider does not return data settlement metadata.
  • data_settlement_blob_id: Walrus blob ID for individual data settlement. None for private/batch settlement or when the provider does not return it.
  • finish_reason: Reason the model stopped generating (e.g. "stop", "tool_call", "error"). Only populated for chat requests.
  • chat_output: Dictionary with the assistant message returned by a chat request. Contains role, content, and optionally tool_calls.
  • completion_output: Raw text returned by a completion request.
  • payment_hash: Payment hash for the x402 transaction.
  • tee_signature: RSA-PSS signature over the response produced by the TEE enclave. Forwarded as-is from the server; verified at settlement on-chain, not by the SDK at return time. See the class-level "Trust model" note above.
  • tee_timestamp: ISO-8601 timestamp from the TEE at signing time. Forwarded as-is alongside tee_signature.

Raises

  • RuntimeError: If the request fails.