Text Generation
Learn how to generate text with Animus models using the REST API
Animus’s text generation capabilities let you create human-like text for a wide range of applications. This guide covers the fundamentals of generating text with our REST API.
Quickstart
To generate text with Animus, you’ll make a request to our chat completions endpoint. Here’s a basic example using direct API calls:
Advanced Usage
Message Roles and Names
When sending messages to the chat completions API, you can use different roles to structure your conversation:
system
: Provides guidance to the model on how to behaveuser
: Represents user inputs in the conversationassistant
: Represents previous responses from the model
Additionally, you can use the name
parameter to give a specific identity to user or assistant messages. This is useful for multi-agent simulations or distinguishing between different participants in a conversation:
The name
parameter must be a string that adheres to the following regex pattern: ^[a-zA-Z0-9_-]{1,64}$
. That means it can contain alphanumeric characters, underscores, and hyphens, with a maximum length of 64 characters.
Controlling Response Format
You can control the format of the responses by providing specific instructions in the system or user messages:
Temperature and Top P
Control the randomness and creativity of responses with these parameters:
- temperature: (0-2) Lower values make output more deterministic; higher values make output more random
- top_p: (0-1) Controls diversity via nucleus sampling
Maximum Tokens
Limit the length of the response by setting a maximum token count:
Streaming Responses
For a more interactive experience, you can stream responses as they’re generated:
Prompt Engineering Best Practices
For better results:
- Be specific: Provide clear instructions with examples
- Use system messages: Set the tone and behavior of the model
- Structure your prompts: Break complex tasks into smaller steps
- Context matters: Provide relevant background information
- Iterate and refine: Test different prompts and learn what works best
Common Use Cases
Animus’s text generation can be used for:
- Content Creation: Generate articles, blog posts, or marketing copy
- Conversational AI: Build chatbots and virtual assistants
- Code Generation: Get help with programming tasks
- Summarization: Condense long texts into concise summaries
- Translation: Convert text between languages
- Creative Writing: Generate stories, poems, or scripts
Error Handling
Implement robust error handling in your applications: