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
The model instance to use for generation.
The text prompt to generate a response for. Either
prompt or messages is required.System instructions to guide the model’s behavior.
Controls randomness. Lower values produce more deterministic responses.
Maximum number of tokens generated.
Nucleus sampling probability.
Limits sampling to the top K probable tokens.
Encourages introducing new topics.
Reduces repeated words or phrases.
Produces deterministic outputs when supported.
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
