MCPcopy
hub / github.com/openai/openai-python / create_variation

Method create_variation

src/openai/resources/images.py:1055–1131  ·  view source on GitHub ↗

Creates a variation of a given image. This endpoint only supports `dall-e-2`. Args: image: The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. model: The model to use for image generation. Only

(
        self,
        *,
        image: FileTypes,
        model: Union[str, ImageModel, None] | Omit = omit,
        n: Optional[int] | Omit = omit,
        response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
        size: Optional[Literal["256x256", "512x512", "1024x1024"]] | Omit = omit,
        user: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    )

Source from the content-addressed store, hash-verified

1053 return AsyncImagesWithStreamingResponse(self)
1054
1055 async def create_variation(
1056 self,
1057 *,
1058 image: FileTypes,
1059 model: Union[str, ImageModel, None] | Omit = omit,
1060 n: Optional[int] | Omit = omit,
1061 response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
1062 size: Optional[Literal["256x256", "512x512", "1024x1024"]] | Omit = omit,
1063 user: str | Omit = omit,
1064 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1065 # The extra values given here take precedence over values defined on the client or passed to this method.
1066 extra_headers: Headers | None = None,
1067 extra_query: Query | None = None,
1068 extra_body: Body | None = None,
1069 timeout: float | httpx.Timeout | None | NotGiven = not_given,
1070 ) -> ImagesResponse:
1071 """Creates a variation of a given image.
1072
1073 This endpoint only supports `dall-e-2`.
1074
1075 Args:
1076 image: The image to use as the basis for the variation(s). Must be a valid PNG file,
1077 less than 4MB, and square.
1078
1079 model: The model to use for image generation. Only `dall-e-2` is supported at this
1080 time.
1081
1082 n: The number of images to generate. Must be between 1 and 10.
1083
1084 response_format: The format in which the generated images are returned. Must be one of `url` or
1085 `b64_json`. URLs are only valid for 60 minutes after the image has been
1086 generated.
1087
1088 size: The size of the generated images. Must be one of `256x256`, `512x512`, or
1089 `1024x1024`.
1090
1091 user: A unique identifier representing your end-user, which can help OpenAI to monitor
1092 and detect abuse.
1093 [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
1094
1095 extra_headers: Send extra headers
1096
1097 extra_query: Add additional query parameters to the request
1098
1099 extra_body: Add additional JSON properties to the request
1100
1101 timeout: Override the client-level default timeout for this request, in seconds
1102 """
1103 body = deepcopy_with_paths(
1104 {
1105 "image": image,
1106 "model": model,
1107 "n": n,
1108 "response_format": response_format,
1109 "size": size,
1110 "user": user,
1111 },
1112 [["image"]],

Callers

nothing calls this directly

Calls 4

deepcopy_with_pathsFunction · 0.85
extract_filesFunction · 0.85
async_maybe_transformFunction · 0.85
make_request_optionsFunction · 0.85

Tested by

no test coverage detected