images.mjs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. import { APIResource } from "../resource.mjs";
  3. import * as Core from "../core.mjs";
  4. export class Images extends APIResource {
  5. /**
  6. * Creates a variation of a given image. This endpoint only supports `dall-e-2`.
  7. *
  8. * @example
  9. * ```ts
  10. * const imagesResponse = await client.images.createVariation({
  11. * image: fs.createReadStream('otter.png'),
  12. * });
  13. * ```
  14. */
  15. createVariation(body, options) {
  16. return this._client.post('/images/variations', Core.multipartFormRequestOptions({ body, ...options }));
  17. }
  18. /**
  19. * Creates an edited or extended image given one or more source images and a
  20. * prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
  21. *
  22. * @example
  23. * ```ts
  24. * const imagesResponse = await client.images.edit({
  25. * image: fs.createReadStream('path/to/file'),
  26. * prompt: 'A cute baby sea otter wearing a beret',
  27. * });
  28. * ```
  29. */
  30. edit(body, options) {
  31. return this._client.post('/images/edits', Core.multipartFormRequestOptions({ body, ...options }));
  32. }
  33. /**
  34. * Creates an image given a prompt.
  35. * [Learn more](https://platform.openai.com/docs/guides/images).
  36. *
  37. * @example
  38. * ```ts
  39. * const imagesResponse = await client.images.generate({
  40. * prompt: 'A cute baby sea otter',
  41. * });
  42. * ```
  43. */
  44. generate(body, options) {
  45. return this._client.post('/images/generations', { body, ...options });
  46. }
  47. }
  48. //# sourceMappingURL=images.mjs.map