-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathimages.ts
More file actions
171 lines (141 loc) · 3.88 KB
/
images.ts
File metadata and controls
171 lines (141 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
export class Images extends APIResource {
/**
* Use an image model to generate an image for a given prompt.
*
* @example
* ```ts
* const imageFile = await client.images.generate({
* model: 'black-forest-labs/FLUX.1-schnell',
* prompt: 'cat floating in space, cinematic',
* });
* ```
*/
generate<Body extends ImageGenerateParams>(
body: Body,
options?: RequestOptions,
): APIPromise<
Omit<ImageFile, 'data'> & {
data: Body['response_format'] extends 'base64' ? ImageDataB64[] : ImageDataURL[];
}
> {
return this._client.post('/images/generations', { body, ...options });
}
}
export interface ImageDataB64 {
b64_json: string;
index: number;
type: 'b64_json';
}
export interface ImageDataURL {
index: number;
type: 'url';
url: string;
}
export interface ImageFile {
id: string;
data: Array<ImageDataB64 | ImageDataURL>;
model: string;
/**
* The object type, which is always `list`.
*/
object: 'list';
}
export interface ImageGenerateParams {
/**
* The model to use for image generation.
*
* [See all of Together AI's image models](https://docs.together.ai/docs/serverless-models#image-models)
*/
model:
| 'black-forest-labs/FLUX.1-schnell-Free'
| 'black-forest-labs/FLUX.1-schnell'
| 'black-forest-labs/FLUX.1.1-pro'
| (string & {});
/**
* A description of the desired images. Maximum length varies by model.
*/
prompt: string;
/**
* If true, disables the safety checker for image generation.
*/
disable_safety_checker?: boolean;
/**
* Adjusts the alignment of the generated image with the input prompt. Higher
* values (e.g., 8-10) make the output more faithful to the prompt, while lower
* values (e.g., 1-5) encourage more creative freedom.
*/
guidance_scale?: number;
/**
* Height of the image to generate in number of pixels.
*/
height?: number;
/**
* An array of objects that define LoRAs (Low-Rank Adaptations) to influence the
* generated image.
*/
image_loras?: Array<ImageGenerateParams.ImageLora>;
/**
* URL of an image to use for image models that support it.
*/
image_url?: string;
/**
* Number of image results to generate.
*/
n?: number;
/**
* The prompt or prompts not to guide the image generation.
*/
negative_prompt?: string;
/**
* The format of the image response. Can be either be `jpeg` or `png`. Defaults to
* `jpeg`.
*/
output_format?: 'jpeg' | 'png';
/**
* An array of image URLs that guide the overall appearance and style of the
* generated image. These reference images influence the visual characteristics
* consistently across the generation.
*/
reference_images?: Array<string>;
/**
* Format of the image response. Can be either a base64 string or a URL.
*/
response_format?: 'base64' | 'url';
/**
* Seed used for generation. Can be used to reproduce image generations.
*/
seed?: number;
/**
* Number of generation steps.
*/
steps?: number;
/**
* Width of the image to generate in number of pixels.
*/
width?: number;
}
export namespace ImageGenerateParams {
export interface ImageLora {
/**
* The URL of the LoRA to apply (e.g.
* https://huggingface.co/strangerzonehf/Flux-Midjourney-Mix2-LoRA).
*/
path: string;
/**
* The strength of the LoRA's influence. Most LoRA's recommend a value of 1.
*/
scale: number;
}
}
export declare namespace Images {
export {
type ImageDataB64 as ImageDataB64,
type ImageDataURL as ImageDataURL,
type ImageFile as ImageFile,
type ImageGenerateParams as ImageGenerateParams,
};
}