pydalle.imperative.api package

Submodules

This module contains the implementations of calls to the Auth0 API.

pydalle.imperative.api.auth0.get_access_token_from_credentials(username: str, password: str, domain: str, client_id: str, audience: str, redirect_uri: str, scope: str, headers: Optional[Dict[str, str]] = None) str
async pydalle.imperative.api.auth0.get_access_token_from_credentials_async(username: str, password: str, domain: str, client_id: str, audience: str, redirect_uri: str, scope: str, headers: Optional[Dict[str, str]] = None) str

Async version of get_access_token_from_credentials()

This module contains the implementations of API calls to the labs API.

pydalle.imperative.api.labs.create_inpainting_task(bearer_token: str, caption: str, masked_image: str, parent_id_or_image: Optional[str] = None, batch_size: int = 3, headers: Optional[Dict[str, str]] = None) Task

Create an “inpainting” task for a given caption and masked image.

Parameters
  • bearer_token – The bearer token to use.

  • caption – The text to generate images for.

  • masked_image – The base64-encoded PNG to mask.

  • parent_id_or_image – The ID of the parent (generation ID or prompt ID) or a base64-encoded PNG

  • batch_size – The number of images to generate per request.

  • headers – Optional headers to send with the request.

async pydalle.imperative.api.labs.create_inpainting_task_async(bearer_token: str, caption: str, masked_image: str, parent_id_or_image: Optional[str] = None, batch_size: int = 3, headers: Optional[Dict[str, str]] = None) Task

Async version of create_inpainting_task()

pydalle.imperative.api.labs.create_text2im_task(bearer_token: str, caption: str, batch_size: int = 4, headers: Optional[Dict[str, str]] = None) Task

Create a “text-to-image” task for a given caption.

Parameters
  • bearer_token – The bearer token to use.

  • caption – The text to generate images for.

  • batch_size – The number of images to generate per request.

  • headers – Optional headers to send with the request.

Returns

The created task, which will either be pending or rejected.

async pydalle.imperative.api.labs.create_text2im_task_async(bearer_token: str, caption: str, batch_size: int = 4, headers: Optional[Dict[str, str]] = None) Task

Async version of create_text2im_task()

pydalle.imperative.api.labs.create_variations_task(bearer_token: str, parent_id_or_image: str, batch_size: int = 3, headers: Optional[Dict[str, str]] = None) Task

Create a “variations” task for a given image.

Parameters
  • bearer_token – The bearer token to use.

  • parent_id_or_image – The ID of the parent (generation ID or prompt ID) or a base64-encoded PNG

  • batch_size – The number of variations to generate per request.

  • headers – Optional headers to send with the request.

Returns

The created task, which will either be pending or rejected.

async pydalle.imperative.api.labs.create_variations_task_async(bearer_token: str, parent_id_or_image: str, batch_size: int = 3, headers: Optional[Dict[str, str]] = None) Task

Async version of create_variations_task()

pydalle.imperative.api.labs.download_generation(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) bytes

Download a generated image by its ID.

Parameters
  • bearer_token – The bearer token to use.

  • generation_id – The ID of the generation to download.

  • headers – Optional headers to send with the request.

Returns

The bytes of the image.

async pydalle.imperative.api.labs.download_generation_async(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) bytes

Async version of download_generation()

pydalle.imperative.api.labs.flag_generation_sensitive(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) UserFlag

Flag a generation as sensitive.

Parameters
  • bearer_token – The bearer token to use.

  • generation_id – The ID of the generation to flag.

  • headers – Optional headers to send with the request.

Returns

The user flag.

async pydalle.imperative.api.labs.flag_generation_sensitive_async(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) UserFlag

Async version of flag_generation_sensitive()

pydalle.imperative.api.labs.flag_generation_unexpected(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) UserFlag

Flag a generation as unexpected.

Parameters
  • bearer_token – The bearer token to use.

  • generation_id – The ID of the generation to flag.

  • headers – Optional headers to send with the request.

Returns

The user flag.

async pydalle.imperative.api.labs.flag_generation_unexpected_async(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) UserFlag

Async version of flag_generation_unexpected()

async pydalle.imperative.api.labs.func(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) Generation

Async version of get_generation()

pydalle.imperative.api.labs.get_access_token(username: str, password: str, headers: Optional[Dict[str, str]] = None) str

Get an access token from the given credentials.

Parameters
  • username – The username or email address associated with the OpenAI account.

  • password – The password associated with the OpenAI account.

  • headers – Optional headers to send with the request.

Returns

An access token, needed for retrieving a labs bearer token.

async pydalle.imperative.api.labs.get_access_token_async(username: str, password: str, headers: Optional[Dict[str, str]] = None) str

Async version of get_access_token()

pydalle.imperative.api.labs.get_bearer_token(username: str, password: str, headers: Optional[Dict[str, str]] = None) str

Get an access token from the given credentials.

Parameters
  • username – The username or email address associated with the OpenAI account.

  • password – The password associated with the OpenAI account.

  • headers – Optional headers to send with the request.

Returns

A bearer token, needed for most API calls.

async pydalle.imperative.api.labs.get_bearer_token_async(username: str, password: str, headers: Optional[Dict[str, str]] = None) str

Async version of get_bearer_token()

pydalle.imperative.api.labs.get_bearer_token_from_access_token(access_token: str, headers: Optional[Dict[str, str]] = None) str

Get a bearer token from the given access token.

Parameters
  • access_token – The access token to use.

  • headers – Optional headers to send with the request.

Returns

A bearer token, needed for most API calls.

async pydalle.imperative.api.labs.get_bearer_token_from_access_token_async(access_token: str, headers: Optional[Dict[str, str]] = None) str

Async version of get_bearer_token_from_access_token()

pydalle.imperative.api.labs.get_credit_summary(bearer_token: str, headers: Optional[Dict[str, str]] = None) BillingInfo

Get the credit summary for the user.

Parameters
  • bearer_token – The bearer token to use.

  • headers – Optional headers to send with the request.

Returns

The billing info.

async pydalle.imperative.api.labs.get_credit_summary_async(bearer_token: str, headers: Optional[Dict[str, str]] = None) BillingInfo

Async version of get_credit_summary()

pydalle.imperative.api.labs.get_generation(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) Generation

Get a generation by its ID.

Parameters
  • bearer_token – The bearer token to use.

  • generation_id – The ID of the generation to get.

  • headers – Optional headers to send with the request.

Returns

The generation.

async pydalle.imperative.api.labs.get_generation_async(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) Generation

Async version of get_generation()

pydalle.imperative.api.labs.get_login_info(access_token: str, headers: Optional[Dict[str, str]] = None) Login

Get the login information for the account authenticated by the given access token.

Parameters
  • access_token – The access token to use.

  • headers – Optional headers to send with the request.

Returns

The login information for the account.

async pydalle.imperative.api.labs.get_login_info_async(access_token: str, headers: Optional[Dict[str, str]] = None) Login

Async version of get_login_info()

pydalle.imperative.api.labs.get_task(bearer_token: str, task_id: str, headers: Optional[Dict[str, str]] = None) Task

Get the task with the given ID for the account authenticated by the given bearer token.

Parameters
  • bearer_token – The bearer token to use.

  • task_id – The ID of the task to get.

  • headers – Optional headers to send with the request.

Returns

The task with the given ID.

async pydalle.imperative.api.labs.get_task_async(bearer_token: str, task_id: str, headers: Optional[Dict[str, str]] = None) Task

Async version of get_task()

pydalle.imperative.api.labs.get_tasks(bearer_token: str, limit: Optional[int] = None, from_ts: Optional[int] = None, headers: Optional[Dict[str, str]] = None) TaskList

Get the list of tasks for the account authenticated by the given bearer token.

Parameters
  • bearer_token – The bearer token to use.

  • from_ts – Optional unix timestamp to exclude tasks created before this time.

  • limit – Optional limit on the number of tasks to return. Server-side and maximum default is 50.

  • headers – Optional headers to send with the request.

Returns

The list of tasks for the account.

async pydalle.imperative.api.labs.get_tasks_async(bearer_token: str, from_ts: Optional[int] = None, limit: Optional[int] = None, headers: Optional[Dict[str, str]] = None) TaskList

Async version of get_tasks()

pydalle.imperative.api.labs.poll_for_task_completion(bearer_token: str, task_id: str, interval: float = 1.0, max_attempts: int = 1000, headers: Optional[Dict[str, str]] = None) Task

Poll for the completion of a task.

Parameters
  • bearer_token – The bearer token to use.

  • task_id – The ID of the task to poll.

  • interval – The interval to wait between requests.

  • max_attempts – The maximum number of times to poll before giving up.

  • headers – Optional headers to send with the request.

Returns

The task with the given ID.

async pydalle.imperative.api.labs.poll_for_task_completion_async(bearer_token: str, task_id: str, interval: float = 1.0, max_attempts: int = 1000, headers: Optional[Dict[str, str]] = None) Task

Async version of poll_for_task_completion()

pydalle.imperative.api.labs.save_generations(bearer_token: str, generation_ids: List[str], collection_id_or_alias='private', headers: Optional[Dict[str, str]] = None) Collection

Save a list of generations by their IDs to a collection.

Parameters
  • bearer_token – The bearer token to use.

  • generation_ids – The IDs of the generations to save.

  • collection_id_or_alias – The ID of the collection to save to. Defaults to your private collection.

  • headers – Optional headers to send with the request.

Returns

The collection with the given ID.

async pydalle.imperative.api.labs.save_generations_async(bearer_token: str, generation_ids: List[str], collection_id_or_alias='private', headers: Optional[Dict[str, str]] = None) Collection

Async version of save_generations()

pydalle.imperative.api.labs.share_generation(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) Generation

Share a generated image by its ID. This makes the image public, making the share_url available for access.

Parameters
  • bearer_token – The bearer token to use.

  • generation_id – The ID of the generation to share.

  • headers – Optional headers to send with the request.

Returns

The shared generation.

async pydalle.imperative.api.labs.share_generation_async(bearer_token: str, generation_id: str, headers: Optional[Dict[str, str]] = None) Generation

Async version of share_generation()

Module contents

This package contains all the modules which actually communicate with external APIs. It does this by facilitating the communication between the functional flows defined in pydalle.functional.api.flow and the code for communicating with the outside world in pydalle.imperative.outside