replicate / replicate-python

Python client for Replicate
https://replicate.com
Apache License 2.0
696 stars 194 forks source link

Poll valid PredictionParams #310

Closed Wheest closed 3 weeks ago

Wheest commented 3 weeks ago

Different models have different prediction parameters (e.g., some look for an image, others look for text input).

It would be useful if the API had an endpoint we could probe to get the input a particular model expects, without running inference.

We could then use this to create the PredictionParams for a given model.

mattt commented 3 weeks ago

Hi @Wheest. That information is available in the schema of the model version you're running.

>>> import replicate
>>> v = replicate.models.get("stability-ai/stable-diffusion-3").latest_version
>>> list(v.openapi_schema["components"]["schemas"]["Input"]["properties"].keys())
['seed', 'image', 'prompt', 'num_outputs', 'aspect_ratio', 'output_format', 'guidance_scale', 'output_quality', 'negative_prompt', 'prompt_strength', 'disable_safety_checker']
Wheest commented 3 weeks ago

Thanks, I couldn't find it in the docs or code!