[フレーム]

API for creating models

Replicate’s API now has an endpoint for creating models.

You can use it to automate the creation of models, including fine-tunes of SDXL and Llama 2.

cURL usage

Here’s an example that uses cURL to create a model with a given owner, name, visibility, and hardware:

curl -s -X POST -H "Authorization: Token $REPLICATE_API_TOKEN" \
 -d '{"owner": "my-username", "name": "my-new-model", "visibility": "public", "hardware": "gpu-a40-large"}' \
 https://api.replicate.com/v1/models

The response is a JSON object of the created model:

{
 "url": "https://replicate.com/my-username/my-new-model",
 "owner": "my-username",
 "name": "my-new-model",
 "description": null,
 "visibility": "public",
 "github_url": null,
 "paper_url": null,
 "license_url": null,
 "run_count": 0,
 "cover_image_url": null,
 "default_example": null,
 "latest_version": null
}

To see all the hardware available for your model to run, consult our endpoint for listing hardware.

curl -s -H "Authorization: Token $REPLICATE_API_TOKEN" \
 https://api.replicate.com/v1/hardware
[
 { "name": "CPU", "sku": "cpu" },
 { "name": "Nvidia T4 GPU", "sku": "gpu-t4" },
 { "name": "Nvidia A40 GPU", "sku": "gpu-a40-small" },
 { "name": "Nvidia A40 (Large) GPU", "sku": "gpu-a40-large" }
]

To compare the price and specifications of these hardware types, check out the pricing page.

JavaScript usage

We’ve added this new operation to the Replicate JavaScript client:

npm install replicate@latest

Then:

import Replicate from "replicate";
const replicate = new Replicate();

// create a new model
const model = await replicate.models.create(
 "my-username", 
 "my-new-model", 
 {
 visibility: "public",
 hardware: "gpu-a40-large"
 }
);
console.log(model)

Python usage

We’ve added this new operation to the Replicate Python client:

pip install --upgrade replicate

Then:

import replicate

model = replicate.models.create(
 owner="my-username",
 name="my-new-model",
 visibility="public",
 hardware="gpu-a40-large",
)
print(model)

Elixir usage

We’ve added this new operation to the Replicate Elixir client:

mix deps.update replicate

Then:

iex> {:ok, model} =
 	Replicate.Models.create(
 		owner: "your-username",
 		name: "my-model",
 		visibility: "public",
		 hardware: "gpu-a40-large"
 		)

API docs

Check out the HTTP API reference for more detailed documentation about this new endpoint.

AltStyle によって変換されたページ (->オリジナル) /