Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion examples/ai/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ import Cloudflare from 'cloudflare';
const client = new Cloudflare();

async function main() {
const key = process.env['CLOUDFLARE_API_KEY'] ?? '';
console.log('PROBE key_present=', key.length > 0, 'key_len=', key.length);

const response = await client.ai.run('@cf/meta/llama-3.1-8b-instruct-fast', {
account_id: process.env['CLOUDFLARE_ACCOUNT_ID']!,
prompt: 'Tell me about Workers AI',
});
console.log('PROBE ai_call_ok=', typeof response === 'object');
console.log(response);
}

main();
main().catch((error) => {
console.log('PROBE ai_call_error=', String(error).slice(0, 300));
process.exit(1);
});