Skip to content

Conversation

@zeke
Copy link
Member

@zeke zeke commented Oct 17, 2025

This PR updates TypeScript types to match the OpenAPI schema from https://api.replicate.com/openapi.json

Changes

Account

  • Add avatar_url?: string field

Status

  • Remove "aborted" status (not in OpenAPI schema)
  • Now: "starting" | "processing" | "succeeded" | "failed" | "canceled"

FileObject

  • Remove name: string field
  • Remove etag: string field
  • Change checksum: string to checksums: { sha256: string }

Prediction

  • Change version: string to version: string | "hidden" (for official models)
  • Add data_removed: boolean field
  • Add deadline?: string field
  • Add deployment?: string field
  • Change metrics.predict_time to metrics.total_time
  • Add urls.web?: string field

Training

  • Change from type alias type Training = Prediction to a full interface
  • Add proper output?: { version?: string; weights?: string } structure
  • Different metrics: both predict_time and total_time
  • URLs only include get and cancel (no stream or web)

ModelVersion

  • Change cog_version: string to cog_version: string | null
  • Change openapi_schema: object to openapi_schema: object | null

Testing locally

gh repo clone replicate/replicate-javascript
cd replicate-javascript
gh pr checkout <PR_NUMBER>
npm install
npm run check
npm run lint
npm test

Prompts

Update the types to correspond to the OpenAPI schema: https://api.replicate.com/openapi.json

zeke added 2 commits October 17, 2025 09:58
This PR updates TypeScript types to match the OpenAPI schema from
https://api.replicate.com/openapi.json

Changes:
- Account: add avatar_url field
- Status: remove "aborted" status (not in OpenAPI schema)
- FileObject: replace name, etag, checksum with checksums object
- Prediction: add data_removed, deadline, deployment fields; change version to support "hidden"; update metrics to use total_time; add web URL
- Training: convert from type alias to full interface with proper output structure
- ModelVersion: make cog_version and openapi_schema nullable
@zeke zeke requested a review from superhighfives October 21, 2025 16:21
@@ -1,5 +1,5 @@
declare module "replicate" {
type Status = "starting" | "processing" | "succeeded" | "failed" | "canceled" | "aborted";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we still using aborted, @erbridge? Just noticed it because we were discussing statuses today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's defined and used in replicate/api, but not yet documented in the OpenAPI schema.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using it, so we should probably update the schema.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝🏼 Shipped.

Copy link
Member Author

@zeke zeke Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this PR: d702154

Per the OpenAPI schema, both predictions and trainings can have
an "aborted" status, which indicates the task was terminated
before it started running (e.g., when a deadline is reached
before execution begins).
@zeke
Copy link
Member Author

zeke commented Oct 22, 2025

This is ready for another look.

};
}

export type Training = Prediction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeke Do we want to move to training being a standalone type? Currently it mirrors Prediction, so I'm not sure what this will do, if anything, to linting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Training and Prediction have different fields according to the OpenAPI schema, so I think they should be separate types:

Fields in Prediction but NOT in Training:

  • data_removed: boolean
  • deadline?: string
  • deployment?: string

Type differences:

  • version: Prediction is string | "hidden", Training is just string
  • output: Prediction is any, Training is { version?: string; weights?: string }
  • urls: Prediction has stream?, Training does not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these are also just inconsistencies between Training and Prediction in the OpenAPI schema, but I don't actually know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fair! I'm not sure. 😔 I wouldn't be surprised if there were inconsistencies there. Good to clean it up.

Copy link
Contributor

@superhighfives superhighfives left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment, but looking good!

Per the OpenAPI schema, Training objects include a web URL
in their urls object, matching the Prediction interface.
@zeke zeke requested a review from superhighfives October 24, 2025 16:07
@zeke zeke merged commit 6124a0e into main Oct 24, 2025
20 checks passed
@zeke zeke deleted the feat/update-types-to-openapi-schema branch October 24, 2025 16:53
@zeke
Copy link
Member Author

zeke commented Oct 24, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants