Code Generation

Code with Llama 2
AI
Hello! I'm an AI code assistant. I can help you write code, explain concepts, or debug issues. What would you like to work on today?
Just now
cURL
Python
JavaScript
bash
curl -X POST https://aireclast.umiteski.workers.dev/api/code/generate \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "prompt": "Write a function to calculate the Fibonacci sequence in JavaScript", "model": "@cf/meta/llama-2-7b-chat-int8" }'
python
import requests import json url = "https://aireclast.umiteski.workers.dev/api/code/generate" headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" } data = { "prompt": "Write a function to calculate the Fibonacci sequence in JavaScript", "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 generateCode() { const url = 'https://aireclast.umiteski.workers.dev/api/code/generate'; const data = { prompt: "Write a function to calculate the Fibonacci sequence in JavaScript", 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 code:', error); } } generateCode();