Types of generations
You can use various methods to generate text, including non-streaming, streaming, and asynchronous completions.Simple generation (non-streaming)
Use the following code to perform text generation with the SambaNova or OpenAI Python client in a non-streaming manner.Asynchronous generation (non-streaming)
For asynchronous completions, use the AsyncSambaNova or AsyncOpenAI Python client.Streaming response
For real-time streaming completions, use the following approach with the SambaNova or OpenAI client.Multiple completions
Use then parameter to generate multiple independent completions for a single prompt. The response includes each completion in choices[0] through choices[n-1].
Set
temperature greater than 0 to get varied outputs across completions. With temperature: 0, all completions will be identical.Model selection
Models differ in their architecture, impacting their speed and response quality. Selecting a model depends on the factors shown below.
Experiment with various models to find the one that best fits your specific use case.
Creating effective prompts
Prompt engineering is the practice of designing and refining prompts to optimize responses from large language models (LLMs). This process is iterative and requires experimentation to achieve the best possible outcomes.Building a prompt
A basic prompt can be as simple as a few words to elicit a response from the LLM. However, for more complex use cases, you may need additional elements:Advanced prompting techniques
To improve response quality and reasoning, more advanced techniques can be used.
For more details about prompt engineering, see A Systematic Survey of Prompt Engineering in Large Language Models: Techniques and Applications.
Messages and roles
In chat-based interactions, messages are represented as dictionaries with specific roles and content.Common roles
Roles are typically categorized assystem, user, or assistant.
Multi-turn conversation
To maintain context across multiple exchanges, messages in a conversational AI system are typically stored as a list of dictionaries. Each dictionary contains keys that specify the sender’s role and the message content. This structure helps the system track context across multiple turns in a conversation. Below is an example of how a multi-turn conversation is structured using the Meta-Llama-3.3-70B-Instruct model:Structuring multi-turn conversations using Meta-Llama-3.3-70B-Instruct
Example output
Considerations for long conversations
When engaging in long conversations with LLMs, certain factors such as token limits and memory constraints must be considered to ensure accuracy and coherence.- Token limits - LLMs have a fixed context window, limiting the number of tokens they can process in a single request. If the input exceeds this limit, the system might truncate it, leading to incomplete or incoherent responses.
- Memory constraints - The model does not retain context beyond its input window. To preserve context, past messages should be re-included in prompts.
DeepSeek-V3.2 thinking mode
DeepSeek-V3.2 supports optional thinking mode, which outputs the model’s reasoning inside<think></think> tags before the final response. Thinking mode is disabled by default. To enable it, pass chat_template_kwargs with enable_thinking set to true in your request.
Thinking mode is available on context block (CB) bundle deployments of DeepSeek-V3.2. Contact your SambaNova administrator to confirm which bundles are available in your environment.
curl
<think></think> tags, followed by the final answer.
Gemma 4 31B thinking mode
Gemma 4 31B (gemma-4-31B-it) supports optional thinking mode, which outputs the model’s reasoning in a separate reasoning field alongside the final response. Thinking mode is disabled by default. To enable it, pass chat_template_kwargs with enable_thinking set to true in your request.
Gemma 4 31B supports tool calling alongside thinking mode. When both are active, the model reasons through the problem and returns its tool call decision in the same response.
Thinking mode is available on all
gemma-4-31b-32-128k bundle deployments.curl
reasoning field with the model’s chain of thought. The final answer appears in content. When tool calling is also active, content is null and the model’s decision appears in tool_calls alongside reasoning.
Example response (thinking mode with tool calling)

