Content Generation¶
Use IndoxHub to generate articles, marketing copy, and creative content.
Blog Post Generator¶
import requests
API_KEY = "YOUR_API_KEY"
def generate_blog_post(topic, tone="professional", word_count=500):
response = requests.post(
"https://api.indoxhub.com/api/v1/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": f"You are a content writer. Write in a {tone} tone. "
f"Target approximately {word_count} words."
},
{
"role": "user",
"content": f"Write a blog post about: {topic}"
}
],
"temperature": 0.8,
"max_tokens": 2000
}
)
return response.json()["data"]
post = generate_blog_post("The future of AI in healthcare")
print(post)
Multi-Format Content¶
Generate the same content in multiple formats:
def generate_multi_format(topic):
formats = {
"tweet": "Write a tweet (under 280 chars)",
"linkedin": "Write a LinkedIn post (2-3 paragraphs)",
"email": "Write a marketing email subject + body",
}
results = {}
for fmt, instruction in formats.items():
response = requests.post(
"https://api.indoxhub.com/api/v1/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "deepseek/deepseek-chat",
"messages": [
{"role": "user", "content": f"{instruction} about: {topic}"}
],
"temperature": 0.9
}
)
results[fmt] = response.json()["data"]
return results
Content with Images¶
Combine text generation with image generation:
def create_illustrated_content(topic):
# Generate article
text_resp = requests.post(
"https://api.indoxhub.com/api/v1/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": f"Write a short article about {topic}"}]
}
)
article = text_resp.json()["data"]
# Generate hero image
img_resp = requests.post(
"https://api.indoxhub.com/api/v1/images/generations",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "openai/dall-e-3",
"prompt": f"Professional illustration for an article about {topic}",
"size": "1792x1024"
}
)
image_url = img_resp.json()["data"][0]["url"]
return {"article": article, "image": image_url}
Tips¶
- Use
deepseek/deepseek-chatfor high-volume content (cheapest option) - Temperature 0.7–0.9 for creative writing, 0.3–0.5 for factual content
- System messages shape tone and style effectively
- Streaming provides better UX for long-form content generation