POST
/
images
/
create
JavaScript
import Weights from '@weights-ai/sdk';

const client = new Weights({
  bearerToken: 'My Bearer Token',
});

const image = await client.images.create({
  prompt: 'A beautiful sunset over mountains with a lake in the foreground',
});

console.log(image.id);
{
  "id": "visual_123456789",
  "status": "SUCCEEDED",
  "prompt": "A beautiful sunset over mountains",
  "type": "IMAGE_GENERATION",
  "numImages": 1,
  "dimensions": "SQUARE",
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:35:00Z",
  "outputUrls": [
    "https://storage.example.com/images/generated_1.jpg"
  ],
  "lora": null,
  "secondaryLora": null
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Response

200
application/json

Returns the ID of the created image generation job.

The response is of type object.