typefile
{
"image": "https://replicate.delivery/pbxt/KZKNhDQHqycw8Op7w056J8YTX5Bnb7xVcLiyB4le7oUgT2cY/moondream2.png",
"prompt": "Describe this image"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_K0T**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run lucataco/moondream2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"lucataco/moondream2:72ccb656353c348c1385df54b237eeb7bfa874bf11486cf0b9473e691b662d31",
{
input: {
image: "https://replicate.delivery/pbxt/KZKNhDQHqycw8Op7w056J8YTX5Bnb7xVcLiyB4le7oUgT2cY/moondream2.png",
prompt: "Describe this image"
}
}
);
console.log(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_K0T**********************************
This is your API token. Keep it to yourself.
import replicate
Run lucataco/moondream2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"lucataco/moondream2:72ccb656353c348c1385df54b237eeb7bfa874bf11486cf0b9473e691b662d31",
input={
"image": "https://replicate.delivery/pbxt/KZKNhDQHqycw8Op7w056J8YTX5Bnb7xVcLiyB4le7oUgT2cY/moondream2.png",
"prompt": "Describe this image"
}
)
# The lucataco/moondream2 model can stream output as it's running.
# The predict method returns an iterator, and you can iterate over that output.
for item in output:
# https://replicate.com/lucataco/moondream2/api#output-schema
print(item, end="")
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_K0T**********************************
This is your API token. Keep it to yourself.
Run lucataco/moondream2 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": "lucataco/moondream2:72ccb656353c348c1385df54b237eeb7bfa874bf11486cf0b9473e691b662d31",
"input": {
"image": "https://replicate.delivery/pbxt/KZKNhDQHqycw8Op7w056J8YTX5Bnb7xVcLiyB4le7oUgT2cY/moondream2.png",
"prompt": "Describe this image"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
The image features a logo with a smiling blue circle above the word "moondream" written in black text.
{
"id": "cn11yqq13xrme0ckkqbs8ct5n8",
"model": "lucataco/moondream2",
"version": "72ccb656353c348c1385df54b237eeb7bfa874bf11486cf0b9473e691b662d31",
"input": {
"image": "https://replicate.delivery/pbxt/KZKNhDQHqycw8Op7w056J8YTX5Bnb7xVcLiyB4le7oUgT2cY/moondream2.png",
"prompt": "Describe this image"
},
"logs": "The attention mask is not set and cannot be inferred from input because pad token is same as eos token.As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.\nThe `seen_tokens` attribute is deprecated and will be removed in v4.41. Use the `cache_position` model input instead.",
"output": [
"",
" ",
"The ",
"image ",
"features ",
"a ",
"logo ",
"with ",
"a ",
"smiling ",
"blue ",
"circle ",
"above ",
"the ",
"word ",
"",
"",
"",
"",
"\"moondream\" ",
"written ",
"in ",
"black ",
"",
"",
"text."
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-12-06T21:19:51.071Z",
"started_at": "2024-12-06T21:20:03.836331Z",
"completed_at": "2024-12-06T21:20:04.402628Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/cn11yqq13xrme0ckkqbs8ct5n8/cancel",
"get": "https://api.replicate.com/v1/predictions/cn11yqq13xrme0ckkqbs8ct5n8",
"stream": "https://stream-b.svc.ric1.c.replicate.net/v1/streams/efp7elvtevbmebfkshm4zxgcpbccnhtq5rshcn5twpyqzk4f7eoq",
"web": "https://replicate.com/p/cn11yqq13xrme0ckkqbs8ct5n8"
},
"metrics": {
"predict_time": 0.566297241,
"total_time": 13.331628
}
}