images.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. "use strict";
  2. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  3. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  4. if (k2 === undefined) k2 = k;
  5. var desc = Object.getOwnPropertyDescriptor(m, k);
  6. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  7. desc = { enumerable: true, get: function() { return m[k]; } };
  8. }
  9. Object.defineProperty(o, k2, desc);
  10. }) : (function(o, m, k, k2) {
  11. if (k2 === undefined) k2 = k;
  12. o[k2] = m[k];
  13. }));
  14. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  15. Object.defineProperty(o, "default", { enumerable: true, value: v });
  16. }) : function(o, v) {
  17. o["default"] = v;
  18. });
  19. var __importStar = (this && this.__importStar) || function (mod) {
  20. if (mod && mod.__esModule) return mod;
  21. var result = {};
  22. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  23. __setModuleDefault(result, mod);
  24. return result;
  25. };
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. exports.Images = void 0;
  28. const resource_1 = require("../resource.js");
  29. const Core = __importStar(require("../core.js"));
  30. class Images extends resource_1.APIResource {
  31. /**
  32. * Creates a variation of a given image. This endpoint only supports `dall-e-2`.
  33. *
  34. * @example
  35. * ```ts
  36. * const imagesResponse = await client.images.createVariation({
  37. * image: fs.createReadStream('otter.png'),
  38. * });
  39. * ```
  40. */
  41. createVariation(body, options) {
  42. return this._client.post('/images/variations', Core.multipartFormRequestOptions({ body, ...options }));
  43. }
  44. /**
  45. * Creates an edited or extended image given one or more source images and a
  46. * prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
  47. *
  48. * @example
  49. * ```ts
  50. * const imagesResponse = await client.images.edit({
  51. * image: fs.createReadStream('path/to/file'),
  52. * prompt: 'A cute baby sea otter wearing a beret',
  53. * });
  54. * ```
  55. */
  56. edit(body, options) {
  57. return this._client.post('/images/edits', Core.multipartFormRequestOptions({ body, ...options }));
  58. }
  59. /**
  60. * Creates an image given a prompt.
  61. * [Learn more](https://platform.openai.com/docs/guides/images).
  62. *
  63. * @example
  64. * ```ts
  65. * const imagesResponse = await client.images.generate({
  66. * prompt: 'A cute baby sea otter',
  67. * });
  68. * ```
  69. */
  70. generate(body, options) {
  71. return this._client.post('/images/generations', { body, ...options });
  72. }
  73. }
  74. exports.Images = Images;
  75. //# sourceMappingURL=images.js.map