Text Generation

Chat with Llama 2
AI
Hello! I'm an AI assistant. How can I help you today?
Just now
cURL
Python
JavaScript
bash
curl -X POST https://aireclast.umiteski.workers.dev/api/text/generate \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "prompt": "Write a short story about a robot learning to paint", "model": "@cf/meta/llama-2-7b-chat-int8" }'
python
import requests import json url = "https://aireclast.umiteski.workers.dev/api/text/generate" headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" } data = { "prompt": "Write a short story about a robot learning to paint", "model": "@cf/meta/llama-2-7b-chat-int8" } response = requests.post(url, headers=headers, data=json.dumps(data)) result = response.json() if response.status_code == 200 and result.get('success'): print(result['data']['result']['response']) else: print(f"Error: {result.get('error', 'Unknown error')}")
javascript
async function generateText() { const url = 'https://aireclast.umiteski.workers.dev/api/text/generate'; const data = { prompt: "Write a short story about a robot learning to paint", model: "@cf/meta/llama-2-7b-chat-int8" }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY' }, body: JSON.stringify(data) }); const result = await response.json(); if (result.success) { console.log(result.data.result.response); } else { console.error('Error:', result.error); } } catch (error) { console.error('Error generating text:', error); } } generateText();