Skip to content

Commit

Permalink
*: improve docs + specify Prodia type (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
montyanderson authored Nov 6, 2023
1 parent ce2f209 commit 17a97fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
25 changes: 22 additions & 3 deletions prodia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,33 @@ export type ProdiaXlGenerateRequest = {

/* Constructor Definions */

export type Prodia = ReturnType<typeof createProdia>;
export type Prodia = {
// sd generations
generate: (params: ProdiaGenerateRequest) => Promise<ProdiaJobQueued>;
transform: (params: ProdiaTransformRequest) => Promise<ProdiaJobQueued>;
controlnet: (params: ProdiaControlnetRequest) => Promise<ProdiaJobQueued>;
inpainting: (params: ProdiaInpaintingRequest) => Promise<ProdiaJobQueued>;

// sdxl generations
xlGenerate: (params: ProdiaXlGenerateRequest) => Promise<ProdiaJobQueued>;

// job info
getJob: (jobId: string) => Promise<ProdiaJob>;
wait: (params: ProdiaJob) => Promise<ProdiaJobSucceeded | ProdiaJobFailed>;

// models
listModels: () => Promise<string[]>;
};

export type CreateProdiaOptions = {
apiKey: string;
base?: string;
};

export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {
export const createProdia = ({
apiKey,
base: _base,
}: CreateProdiaOptions): Prodia => {
const base = _base || "https://api.prodia.com/v1";

const headers = {
Expand Down Expand Up @@ -215,7 +234,7 @@ export const createProdia = ({ apiKey, base: _base }: CreateProdiaOptions) => {
return (await response.json()) as ProdiaJob;
};

const wait = async (job: ProdiaJobQueued | ProdiaJobGenerating) => {
const wait = async (job: ProdiaJob) => {
let jobResult: ProdiaJob = job;

while (
Expand Down
34 changes: 0 additions & 34 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,3 @@ const prodia = createProdia({
// check status and view your image :)
})();
```

## API

### `createProdia(opts)` => `Prodia`

Create a new Prodia object.

#### `opts`

- `apiKey` (`string`)

Your API key from the Prodia dashboard.

- `base` (`string`)

Optional: an enterprise-specific Prodia island.

#### `Prodia`

##### `generate(` `params` `)` => `ProdiaJob`

Create a new text to image job.

Supports all parameters [listed in the documentation](https://docs.prodia.com/reference/generate).

##### `transform(` `params` `)` => `ProdiaJob`

Create a new image to image job.

Supports all parameters [listed in the documentation](https://docs.prodia.com/reference/transform).

##### `wait(` `ProdiaJob` `)` => `{` `status`, `imageUrl` `}`

Returns once as job has completed.

0 comments on commit 17a97fe

Please sign in to comment.