Text Generation models receive text instructions, questions, or context and generate natural language responses. They are suitable for general language tasks such as open-ended conversation, knowledge Q&A, content generation, summarization, rewriting, and task decomposition.
Representative models include:
DeepSeek-V4-Flash
DeepSeek-V4-Pro
Qwen/Qwen3-32B
openai/gpt-oss-120b
For the full model list and pricing, refer to Models.
Core Capabilities
Text Generation models are typically used for the following capability scenarios. Specific support and performance vary by model.
Code generation and mathematical reasoning, such as implementing functions from natural language, refactoring code, writing unit tests, and solving problems step by step, are usually also handled by these general-purpose models. We recommend using a lower temperature, such as 0.1-0.3, for more stable and predictable output.
Use Cases
- Open-ended conversation: Customer support bots, FAQ assistants, and conversational agents.
- Knowledge Q&A: Enterprise knowledge bases, document retrieval, and factual or procedural answers.
- Content generation: Marketing copy, summaries, long-form articles, and creative writing.
- Instruction following: Task decomposition, step-by-step guides, and structured outputs such as lists and tables.
Message Structure
Text Generation models receive input through a list of messages. Common message roles are as follows:
Organizing prompts in layers such as system > user > assistant history usually makes output more stable. You can also try different prompt structures based on your scenario.
Key Parameters
Description
-
Parameters that control creativity
temperature: Controls output randomness. The value range is 0.0-2.0, and the recommended range is 0.2-0.8 to balance creativity and stability.
top_p: Controls the sampling range. The value range is 0.0-1.0. It can be used together with temperature to adjust creativity and stability.
-
Parameters that control output
-
max_completion_tokens: Limits generation length and helps avoid truncated output.
-
stop: Sets stop sequences. Used to control where the model stops generating.
-
frequency_penalty: Repetition penalty. If output is repetitive or garbled, try adjusting this value.
-
stream=True: Returns responses as a stream. Recommended for long responses to reduce timeout risk.
-
Context
The maximum context length supported by each model can be viewed in Models.
Recommendations
- If output is garbled, try adjusting
temperature, top_p, and frequency_penalty.
- We recommend keeping
max_completion_tokens within the maximum context length and leaving room for the input.
- If output is truncated, set a reasonable
max_completion_tokens, enable stream=True, and increase the client timeout.
Billing
- Formula: Total cost = (input tokens x input unit price) + (output tokens x output unit price).
- Pricing: Check the model detail page in Models for each model’s pricing.
- Recommendations:
- During development, prefer free or lower-cost models.
- For long responses, use streaming output and set
max_completion_tokens appropriately.
- For high-QPS workloads, combine concurrency control and rate limiting strategies.
Examples
The examples read the API key from an environment variable to avoid writing secrets into code.
Multi-Turn Conversation
Data Analysis Content Generation
Release Notes / Changelog