Learning resourcesReviewed · xAI

xAI Generate Text: Responses API Guide

xAI’s Generate Text guide teaches developers to generate text and build conversations with Grok, with conversation history stored on the provider’s servers for 30 days by default. It explains response IDs, storage opt-out, encrypted reasoning state, retrieval and deletion through REST and several SDKs. Pricing and model quality are not established by this page.

Researched 15 Nov 2026

In short.

xAI’s Generate Text guide helps developers add Grok text generation and conversations to applications, with server storage of conversation history enabled for 30 days by default. Its examples cover raw HTTP, Python and JavaScript OpenAI SDK clients pointed at xAI, the Vercel AI SDK and xAI’s Python SDK. The central decision is whether to continue conversations through stored response IDs or maintain history locally. The page documents storage controls and encrypted reasoning content, but does not establish pricing, model quality, SDK version compatibility or broader data-handling terms. Nothing was executed; the examples and API behavior remain untested.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage comprises the complete selected Generate Text documentation page at the exact supplied address, including all examples, notes, storage controls and response lifecycle operations. Linked reasoning documentation, SDK repositories, console pages and other linked resources are excluded. The page was captured in full on 2026-11-15 and has no accompanying downloadable files. No redistribution licence is stated. No code or API request was executed, and behavior, performance, pricing and linked claims remain untested or unknown where specified.

The overview

Identity

Generate Text is an xAI developer documentation guide to text generation and conversation management. The selected page is [https://docs.x.ai/developers/model-capabilities/text/generate-text.md]. It presents the Responses API as xAI’s preferred API interface and uses grok-4.7 in its examples.

The resource is a guide to a hosted API. Its examples show requests to [https://api.x.ai/v1/responses] and several client libraries.

Assessment

The guide is useful for implementing the basic lifecycle of a text conversation: create a response, continue it, retrieve it and delete it. Its most consequential detail is the default retention of prompts, reasoning content and model responses on the provider’s servers.

The concrete request examples support implementation planning. They do not establish answer accuracy, reliability, performance or suitability for a particular production application.

Who it is for

The guide fits developers building chatbots or adding generated text to applications. Beginners get explicit request examples and a practical explanation of continuing a conversation through a response ID. Readers still need familiarity with API credentials and editing code or HTTP requests.

Experienced developers can use the storage controls, response lifecycle operations and encrypted reasoning examples when deciding how their application will manage conversation state.

Documented capabilities

The page documents generating a response from system and user messages, obtaining its ID, and continuing with previous_response_id plus new input. It also shows retrieving and deleting a stored response by ID.

Storage can be disabled with store: false in Responses API requests or store_messages=False in the xAI Python SDK. Reasoning models can return encrypted reasoning content for use in subsequent requests.

Using it

Requirements

The stated prerequisite is an API key created through the xAI Console. The page shows exporting it as XAI_API_KEY. Calling the hosted endpoint also requires network access and an HTTP client or a compatible SDK.

Examples use curl, the Python or JavaScript OpenAI SDK, the Vercel AI SDK packages ai and @ai-sdk/xai, and xai_sdk for Python. Package versions and runtime requirements are not specified. The native Python examples also read XAI_MANAGEMENT_API_KEY, but the page does not explain whether it is required for these text-generation calls.

How conversation state works

A response ID acts as a reference to conversation history stored by the provider. Passing that ID as previous_response_id lets the next request append messages without resending the full conversation. The documented retention period is 30 days, after which the stored response is removed.

For conversations that must continue beyond that period, the page instructs developers to retain history and encrypted thinking content locally and include them in a new request. Disabling server storage likewise makes local history management an application responsibility.

Setup

Create an xAI API key and configure the chosen client to use it. For the OpenAI SDK examples, set base_url in Python or baseURL in JavaScript to [https://api.x.ai/v1]. Raw HTTP requests use bearer authentication.

Choose the storage behavior before sending conversation data. Set store to false to disable the response-history storage described by the page, or retain response IDs for server-based continuation. The examples set long timeouts, which the code comments attribute to reasoning models: 3600 seconds in the Python, curl and xAI SDK examples, but 360000 milliseconds (6 minutes) in the JavaScript OpenAI SDK examples. The page gives no latency measurements.

Example use

The documented conversation starts with the question “How big is the universe?” using grok-4.7. The application saves response.id, then sends “How do stars form?” as new user input with previous_response_id set to that saved ID.

This illustrates continuing a stored conversation within the retention window. Separate examples show replaying response.output with a follow-up message when carrying output forward explicitly. These are documentation examples; no request was executed or answer quality assessed.

Assessment & evidence

Limitations

Stored response IDs have a documented 30-day usefulness window. Applications needing longer continuity must preserve the necessary history locally. Context limits, rate limits, error handling and retry behavior are not established here.

The page says the Vercel AI SDK does not provide retrieval or deletion methods for previous responses and directs readers to OpenAI SDK examples for those operations.

No execution results, benchmarks or independent quality measurements are supplied. The model identifier and client examples are documented, but their current availability and compatibility have not been verified.

Encrypted reasoning content

Encrypted reasoning content is model state that the page shows carrying into later requests. Responses API requests can ask for it through include: ["reasoning.encrypted_content"], while the xAI SDK uses use_encrypted_content=True. The page specifies using a reasoning model.

The page says grok-4.7 always returns reasoning.encrypted_content through the Responses API. Its Vercel AI SDK guidance separately says automatic inclusion applies when store: false is not set. The exact wrapper behavior with storage disabled is not demonstrated.

The guide does not provide a method for reading or decrypting this content. Its practical value here is preserving state across requests; it supplies no evidence that this improves answer quality.

Implementation alternatives

Within the page, developers can choose raw REST requests, OpenAI SDK clients configured for xAI, the Vercel AI SDK or xAI’s Python SDK. The page says the native Python SDK uses gRPC and covers additional xAI products, while describing Responses API as suited to chatbots and REST-based use.

The guide contrasts response-ID continuation with Chat Completions requests that resend previous messages. It provides no comparative cost or performance results, and does not assess other providers.

Evidence

The source is the complete Generate Text page at [https://docs.x.ai/developers/model-capabilities/text/generate-text.md], captured in full on 2026-11-15. It contains explanatory text and examples for creation, storage opt-out, encrypted reasoning, continuation, retrieval and deletion.

Behavioral claims come from this documentation; no execution receipts or independent measurements are supplied.

Access & freshness

Costs

The page supplies no token prices, free allowance or charges for storage, retrieval and deletion. It also does not explain how earlier conversation content is billed when using previous_response_id.

API usage costs and the total cost of a representative conversation are unknown from this source. Reduced request payloads do not establish any billing savings.

Rights and data handling

The selected page states no licence for the document or its code examples, and does not establish generated-output ownership or commercial-use permissions. Those rights are unknown from this source.

The documented storage opt-out concerns previous request and response storage. The page does not establish broader logging practices, training use, data residency or the scope and timing of deletion beyond the described stored-response operations.

Freshness

The supplied snapshot was captured on 2026-11-15 at 13:22:51.174 UTC. The page uses grok-4.7 throughout its examples, but supplies no publication date, last-update date or SDK version pins.

The capture timestamp identifies this snapshot; it does not establish when the documented behavior began or guarantee that API behavior and client compatibility remain unchanged.

Practical next steps

Decide whether the documented 30-day server storage fits the application’s data requirements. Configure store explicitly, choose a supported client route, and plan local history retention if conversations must survive beyond the response-ID window.

Before committing to an integration, confirm model access, SDK versions, pricing, usage limits and applicable terms. Validate creation, continuation, storage opt-out, retrieval and deletion with non-sensitive sample data. These actions are recommendations; none has been performed.

Evidence for this report

selected-page.txtselected · checked 2026-11-15