Text Generation
UsegenerateText() for standard, non-streaming responses.
Streaming Responses
UsestreamText() to stream tokens as they are generated.
System Prompts & Parameters
You can customize model behavior using a system prompt and generation parameters.Supported Parameters
LanguageModel
required
The model instance to use for generation.
string
The text prompt to generate a response for. Either
prompt or messages is required.string
System instructions to guide the model’s behavior.
number
Controls randomness. Lower values produce more deterministic responses.
number
Maximum number of tokens generated.
number
Nucleus sampling probability.
number
Limits sampling to the top K probable tokens.
number
Encourages introducing new topics.
number
Reduces repeated words or phrases.
number
Produces deterministic outputs when supported.
string[]
Stops generation when one of the specified sequences is encountered.
Error Handling
Wrap SDK calls in atry...catch block to handle API errors, validation failures, and authentication issues.
- Invalid API key
- Incorrect endpoint URL
- Unsupported model
- Invalid request parameters
- Rate limits
