typetext
{
"frequency_penalty": 0,
"image_input": [],
"max_completion_tokens": 4096,
"presence_penalty": 0,
"prompt": "Who was the 16th president of the United States?",
"system_prompt": "You are a helpful assistant.",
"temperature": 1,
"top_p": 1
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_dzo**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run openai/gpt-4o using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const input = {
frequency_penalty: 0,
image_input: [],
max_completion_tokens: 4096,
presence_penalty: 0,
prompt: "Who was the 16th president of the United States?",
system_prompt: "You are a helpful assistant.",
temperature: 1,
top_p: 1
};
for await (const event of replicate.stream("openai/gpt-4o", { input })) {
process.stdout.write(event.toString());
};
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_dzo**********************************
This is your API token. Keep it to yourself.
import replicate
Run openai/gpt-4o using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
# The openai/gpt-4o model can stream output as it's running.
for event in replicate.stream(
"openai/gpt-4o",
input={
"frequency_penalty": 0,
"image_input": [],
"max_completion_tokens": 4096,
"presence_penalty": 0,
"prompt": "Who was the 16th president of the United States?",
"system_prompt": "You are a helpful assistant.",
"temperature": 1,
"top_p": 1
},
):
print(str(event), 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_dzo**********************************
This is your API token. Keep it to yourself.
Run openai/gpt-4o 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 $'{
"input": {
"frequency_penalty": 0,
"image_input": [],
"max_completion_tokens": 4096,
"presence_penalty": 0,
"prompt": "Who was the 16th president of the United States?",
"system_prompt": "You are a helpful assistant.",
"temperature": 1,
"top_p": 1
}
}' \
https://api.replicate.com/v1/models/openai/gpt-4o/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
The 16th president of the United States was Abraham Lincoln. He served from March 4, 1861, until his assassination on April 15, 1865.
{
"id": "6vpwwwbvgnrmc0cqn71v6qnpg4",
"model": "openai/gpt-4o",
"version": "hidden",
"input": {
"frequency_penalty": 0,
"image_input": [],
"max_completion_tokens": 4096,
"presence_penalty": 0,
"prompt": "Who was the 16th president of the United States?",
"system_prompt": "You are a helpful assistant.",
"temperature": 1,
"top_p": 1
},
"logs": "Input token count: 29\nOutput token count: 36\nTotal token count: 65\nTTFT: 0.54s",
"output": [
"",
"The",
" ",
"16",
"th",
" president",
" of",
" the",
" United",
" States",
" was",
" Abraham",
" Lincoln",
".",
" He",
" served",
" from",
" March",
" ",
"4",
",",
" ",
"186",
"1",
",",
" until",
" his",
" assassination",
" on",
" April",
" ",
"15",
",",
" ",
"186",
"5",
".",
"",
""
],
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2025-06-26T01:04:10.117Z",
"started_at": "2025-06-26T01:04:10.133858Z",
"completed_at": "2025-06-26T01:04:11.280083Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/6vpwwwbvgnrmc0cqn71v6qnpg4/cancel",
"get": "https://api.replicate.com/v1/predictions/6vpwwwbvgnrmc0cqn71v6qnpg4",
"stream": "https://stream-b.svc.ric1.c.replicate.net/v1/streams/gvfk3h7ccpx7npar36yxlyqh37urgenppxkixrvzztm42vvx7vzq",
"web": "https://replicate.com/p/6vpwwwbvgnrmc0cqn71v6qnpg4"
},
"metrics": {
"input_token_count": 29,
"output_token_count": 36,
"predict_time": 1.146225139,
"time_to_first_token": 0.560034565,
"tokens_per_second": 59.696683736789666,
"total_time": 1.163083
}
}