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

Method create_variation

src/openai/resources/images.py:50–126  ·  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

48 return ImagesWithStreamingResponse(self)
49
50 def create_variation(
51 self,
52 *,
53 image: FileTypes,
54 model: Union[str, ImageModel, None] | Omit = omit,
55 n: Optional[int] | Omit = omit,
56 response_format: Optional[Literal["url", "b64_json"]] | Omit = omit,
57 size: Optional[Literal["256x256", "512x512", "1024x1024"]] | Omit = omit,
58 user: str | Omit = omit,
59 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
60 # The extra values given here take precedence over values defined on the client or passed to this method.
61 extra_headers: Headers | None = None,
62 extra_query: Query | None = None,
63 extra_body: Body | None = None,
64 timeout: float | httpx.Timeout | None | NotGiven = not_given,
65 ) -> ImagesResponse:
66 """Creates a variation of a given image.
67
68 This endpoint only supports `dall-e-2`.
69
70 Args:
71 image: The image to use as the basis for the variation(s). Must be a valid PNG file,
72 less than 4MB, and square.
73
74 model: The model to use for image generation. Only `dall-e-2` is supported at this
75 time.
76
77 n: The number of images to generate. Must be between 1 and 10.
78
79 response_format: The format in which the generated images are returned. Must be one of `url` or
80 `b64_json`. URLs are only valid for 60 minutes after the image has been
81 generated.
82
83 size: The size of the generated images. Must be one of `256x256`, `512x512`, or
84 `1024x1024`.
85
86 user: A unique identifier representing your end-user, which can help OpenAI to monitor
87 and detect abuse.
88 [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
89
90 extra_headers: Send extra headers
91
92 extra_query: Add additional query parameters to the request
93
94 extra_body: Add additional JSON properties to the request
95
96 timeout: Override the client-level default timeout for this request, in seconds
97 """
98 body = deepcopy_with_paths(
99 {
100 "image": image,
101 "model": model,
102 "n": n,
103 "response_format": response_format,
104 "size": size,
105 "user": user,
106 },
107 [["image"]],

Calls 4

deepcopy_with_pathsFunction · 0.85
extract_filesFunction · 0.85
maybe_transformFunction · 0.85
make_request_optionsFunction · 0.85