Skip to main content
Fireworks /

Playground v2 1024

accounts/fireworks/models/playground-v2-1024px-aesthetic

ServerlessImageImg2Img

Playground v2 is a diffusion-based text-to-image generative model. The model was trained from scratch by the research team at playground.com.

Serverless API

Playground v2 1024 is available via Fireworks' serverless image API, where you pay per image step (per generated image) and do not need to configure GPUs.

The Fireworks image generation API can be called by making HTTP requests from any language. We also provide a Python client library that you can use to easily call the API.

Try it

API Examples

Generate a model response using the image endpoint of playground-v2-1024px-aesthetic. API reference

# pip install 'fireworks-ai'
import fireworks.client
from fireworks.client.image import ImageInference, Answer

# Initialize the ImageInference client
fireworks.client.api_key = "$API_KEY"
inference_client = ImageInference(model="accounts/fireworks/models/playground-v2-1024px-aesthetic")

# Generate an image using the text_to_image method
answer : Answer = inference_client.text_to_image(
    prompt="A beautiful sunset over the ocean",
    cfg_scale=undefined,
    height=1024,
    width=1024,
    sampler=None,
    steps=undefined,
    seed=0,
    safety_check=False,
    output_image_format="JPG",
    # Add additional parameters here
)

if answer.image is None:
  raise RuntimeError(f"No return image, {answer.finish_reason}")
else:
  answer.image.save("output.jpg")

Calling the API

The Fireworks image generation API can be called by making HTTP requests from any language. We also provide a Python client library that you can use to easily call the API.

Instructions for deploying on-demand deployments for these models can be found on the model HuggingFace pages.

Below we describe the raw REST API for making requests to the API. For easy generation of calls, see the console above.

Authentication

All API calls require a valid authentication token. You can obtain a token from the Fireworks console. When calling the API, make sure to specify the Authentication header, with your token after the word Bearer. For example: Authorization: Bearer abcd1234defg5678hijk9012lmno3456pqrs7890tuvw1234.

File Uploads (image_to_image and control_net)

Since image_to_image and control_net require uploading binary image files, the APIs are designed around the multipart/form-data content type. This means that forming your query is not as simple as writing a JSON response body, as with text-to-image. See information about how to make these requests in Python requests, node.js fetch, and cURL.

Image Generation Modes

Generate an image from a text prompt

POST https://api.fireworks.ai/inference/v1/image_generation/accounts/fireworks/models/playground-v2-1024px-aesthetic HTTP/1.1

Request Headers

Request Parameters

Response Codes