Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/components/models/code/Flux-1-Schnell.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default {
async fetch(request, env): Promise<Response> {
const response = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', {
prompt: 'a cyberpunk lizard',
seed: Math.floor(Math.random() * 10)
});
// response.image is base64 encoded which can be used directly as an <img src=""> data URI
const dataURI = \`data:image/jpeg;charset=utf-8;base64,\${response.image}\`;
Expand All @@ -38,6 +39,7 @@ export default {
async fetch(request, env): Promise<Response> {
const response = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', {
prompt: 'a cyberpunk lizard',
seed: Math.floor(Math.random() * 10)
});
// Convert from base64 string
const binaryString = atob(response.image);
Expand All @@ -56,7 +58,7 @@ const curl = `
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/${name} \\
-X POST \\
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \\
-d '{ "prompt": "cyberpunk cat" }'
-d '{ "prompt": "cyberpunk cat", "seed": "Random positive integer" }'
`;
---

Expand Down