Run Models

replicate/skills/skills/run-models

作者 replicate2f36e415965a无许可证98 个星标收录于 2026年10月8日更新于 2026年10月8日仓库4个月前更新

Run AI models on Replicate via predictions, webhooks, and streaming.

仅含说明AI & Agents
AI 生成的概览

指导通过预测、Webhook、轮询和流式传输在 Replicate 上运行 AI 模型。

功能
该技能提供调用 Replicate API 运行 AI 模型的说明。内容涵盖选择模型、获取其架构、创建预测、通过轮询或 Webhook 获取结果、流式输出、处理文件以及将多个模型串联为多模型工作流。它产出的是预测结果和输出 URL,而非文件或代码。
适用场景
当智能体需要在 Replicate 上调用托管的 AI 模型(如图像、视频或语言模型)时使用。适用于需要创建预测、异步获取结果或串联多个模型输出的任务。
运行要求
需要访问 Replicate API 的网络连接以及用于身份验证的 API 令牌。不包含脚本,仅为说明文档。

Docs

Workflow

  1. Choose the right model - Search with the API or ask the user.
  2. Get model metadata - Fetch input and output schema via API.
  3. Create prediction - POST to /v1/predictions.
  4. Poll for results - GET prediction until status is "succeeded".
  5. Return output - Usually URLs to generated content.

Three ways to get output

  1. Create a prediction, store its id from the response, and poll until completion.
  2. Set a Prefer: wait header when creating a prediction for a blocking synchronous response. Only recommended for very fast models. Max 60 seconds.
  3. Set an HTTPS webhook URL when creating a prediction, and Replicate will POST to that URL when the prediction completes.

Guidelines

  • Use the POST /v1/predictions endpoint, as it supports both official and community models.
  • Every model has its own OpenAPI schema. Always fetch and check model schemas to make sure you're setting valid inputs. Even popular models change their schemas.
  • Validate input parameters against schema constraints (minimum, maximum, enum values). Don't generate values that violate them.
  • When unsure about a parameter value, use the model's default example or omit the optional parameter.
  • Don't set optional inputs unless you have a reason to. Stick to the required inputs and let the model's defaults do the work.
  • Use HTTPS URLs for file inputs whenever possible. You can also send base64-encoded files, but they should be avoided.
  • Fire off multiple predictions concurrently. Don't wait for one to finish before starting the next.
  • Output file URLs expire after 1 hour, so back them up if you need to keep them, using a service like Cloudflare R2.
  • Webhooks are a good mechanism for receiving and storing prediction output.

Predictions

  • A prediction goes through these states: starting -> processing -> succeeded / failed / canceled.
  • Official models use owner/name format. Community models require owner/name:version_id.
  • The POST /v1/predictions endpoint handles both.

Webhooks

  • Set webhook to an HTTPS URL when creating a prediction. Replicate POSTs the full prediction object when it completes.
  • Filter events with webhook_events_filter: start, output, logs, completed.
  • Validate webhook signatures using the Webhook-ID, Webhook-Timestamp, and Webhook-Signature headers. Get the signing secret from GET /v1/webhooks/default/secret.

Prediction lifetime

  • Set lifetime to auto-cancel predictions that run too long (e.g. 30s, 5m, 1h). Measured from creation time.

Streaming

  • Language models that support streaming include a stream URL in the response. Use SSE to receive incremental output.

File handling

  • Prefer HTTPS URLs for file inputs. Output URLs from one prediction can be passed directly as file inputs to the next model.
  • Output file URLs expire after 1 hour. Download and store them immediately if you need to keep them.

Multi-model workflows

  • Chain models by passing output URLs as file inputs to the next model.
  • Start all independent predictions in parallel, then collect results.
  • Output URLs are valid for 1 hour, which is enough for pipeline steps.

来源与署名

来源:replicate/skills位于skills/run-models提交2f36e41

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架