stable-diffusion-xl-base-1.0
Model ID: @cf/stabilityai/stable-diffusion-xl-base-1.0
Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts.
More Information Terms & License
Properties
Task Type: Text-to-Image
Code Examples
Workers - TypeScript
import { Ai } from "@cloudflare/ai";
export interface Env { AI: Ai;
}
export default { async fetch(request: Request, env: Env) { const ai = new Ai(env.AI);
const inputs = { prompt: "cyberpunk cat", };
const response = await ai.run( "@cf/stabilityai/stable-diffusion-xl-base-1.0", inputs );
return new Response(response, { headers: { "content-type": "image/png", }, }); },
};
curl
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/stabilityai/stable-diffusion-xl-base-1.0 \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "prompt": "cyberpunk cat" }'
Response
The response is a binary PNG file.
API Schema
The following schema is based on JSON SchemaInput JSON Schema
Output JSON Schema