-
Notifications
You must be signed in to change notification settings - Fork 0
generate
gitpavleenbali edited this page Feb 17, 2026
·
2 revisions
The generate function creates various types of content using AI.
from pyai import generate# Generate content
content = generate("blog post about Python")
# With type specification
email = generate("thank you email", type="email")
# Async version
content = await generate.async_("product description")| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
str | required | Description of content to generate |
type |
str | None | Content type: "email", "blog", "code", "story" |
tone |
str | "professional" | Tone: "formal", "casual", "professional" |
length |
str | "medium" | Length: "short", "medium", "long" |
format |
str | None | Output format: "markdown", "html", "plain" |
| Type | Description |
|---|---|
email |
Professional emails |
blog |
Blog posts and articles |
code |
Code snippets |
story |
Creative stories |
report |
Business reports |
documentation |
Technical docs |
from pyai import generate
email = generate(
"thank customer for purchase",
type="email",
tone="friendly"
)
print(email)blog = generate(
"introduction to machine learning",
type="blog",
length="long",
format="markdown"
)docs = generate(
"API documentation for user authentication",
type="documentation"
)code = generate(
"Python function to validate email addresses",
type="code"
)import asyncio
from pyai import generate
async def main():
content = await generate.async_(
"product launch announcement",
type="email"
)
print(content)
asyncio.run(main())# Use predefined templates
content = generate.from_template(
"newsletter",
topic="Monthly Update",
highlights=["Feature A", "Feature B"]
)Intelligence, Embedded.