{}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_bD4**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
import fs from "node:fs";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run zeke/haiku-image using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"zeke/haiku-image:7d12600de43acbd73ca6a192fbd1f6d8dabaedb191a49cf93ab2d6ce86fd7b0a",
{
input: {}
}
);
// To access the file URL:
console.log(output.url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_bD4**********************************
This is your API token. Keep it to yourself.
import replicate
Run zeke/haiku-image using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"zeke/haiku-image:7d12600de43acbd73ca6a192fbd1f6d8dabaedb191a49cf93ab2d6ce86fd7b0a",
input={}
)
# To access the file URL:
print(output.url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output.read())
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_bD4**********************************
This is your API token. Keep it to yourself.
Run zeke/haiku-image using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "zeke/haiku-image:7d12600de43acbd73ca6a192fbd1f6d8dabaedb191a49cf93ab2d6ce86fd7b0a",
"input": {}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "extognnrurfwhiekqjtxocfezi",
"model": "zeke/haiku-image",
"version": "7d12600de43acbd73ca6a192fbd1f6d8dabaedb191a49cf93ab2d6ce86fd7b0a",
"input": {},
"logs": "",
"output": "https://replicate.delivery/mgxm/77db88dd-7364-4b61-aa21-e7fbfc87a34f/haiku.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-03-01T16:42:56.509348Z",
"started_at": "2022-03-01T16:42:56.68384Z",
"completed_at": "2022-03-01T16:42:57.80313Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/extognnrurfwhiekqjtxocfezi/cancel",
"get": "https://api.replicate.com/v1/predictions/extognnrurfwhiekqjtxocfezi"
},
"metrics": {
"predict_time": 1.11929,
"total_time": 1.293782
}
}