stable-diffusion-xl-base-1.0
   Beta  
       
  Terminal window     
       
         
     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.
Properties
Task Type: Text-to-Image
Code Examples
Workers - Typescript
  export interface Env {  AI: Ai;}
export default {  async fetch(request, env): Promise<Response> {
    const inputs = {      prompt: "cyberpunk cat",    };
    const response = await env.AI.run(      "@cf/stabilityai/stable-diffusion-xl-base-1.0",      inputs    );
    return new Response(response, {      headers: {        "content-type": "image/png",      },    });  },} satisfies ExportedHandler<Env>;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 Schema
Input JSON Schema
  {  "type": "object",  "properties": {    "prompt": {      "type": "string",      "minLength": 1    },    "negative_prompt": {      "type": "string"    },    "height": {      "type": "integer",      "maximum": 1024    },    "width": {      "type": "integer",      "maximum": 1024    },    "image": {      "type": "array",      "items": {        "type": "number"      }    },    "image_b64": {      "type": "string"    },    "mask": {      "type": "array",      "items": {        "type": "number"      }    },    "num_steps": {      "type": "integer",      "default": 20,      "maximum": 20    },    "strength": {      "type": "number",      "default": 1    },    "guidance": {      "type": "number",      "default": 7.5    },    "seed": {      "type": "integer"    }  },  "required": [    "prompt"  ]}Output JSON Schema
  {  "type": "string",  "contentType": "image/png",  "format": "binary"}