cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
examples/demo.ts
17lines · modeblame
2d51afdcstainless-app[bot]2 years ago | 1 | #!/usr/bin/env -S npm run tsn -T |
| 2 | | |
| 3 | import Cloudflare from 'cloudflare'; | |
| 4 | | |
| 5 | // gets API Key from environment variable CLOUDFLARE_API_KEY & CLOUDFLARE_EMAIL | |
| 6 | const client = new Cloudflare(); | |
| 7 | | |
| 8 | async function main() { | |
| 9 | const accountId = '<your accound ID>'; | |
| 10 | | |
| 11 | const response = await client.ai.run(accountId, '@cf/meta/llama-2-7b-chat-int8', { | |
| 12 | prompt: 'Tell me about Workers AI', | |
| 13 | }); | |
| 14 | console.log(response); | |
| 15 | } | |
| 16 | | |
| 17 | main(); |