default```py
print("hello world")
```
typetext
{
"markdown": "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_K21**********************************
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/cog-markdown-example using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"zeke/cog-markdown-example:146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
{
input: {
markdown: "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
}
}
);
// 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_K21**********************************
This is your API token. Keep it to yourself.
import replicate
Run zeke/cog-markdown-example using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"zeke/cog-markdown-example:146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
input={
"markdown": "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
}
)
# 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_K21**********************************
This is your API token. Keep it to yourself.
Run zeke/cog-markdown-example 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/cog-markdown-example:146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
"input": {
"markdown": "```py\\ndef allow_iframe_youtube(tag, name, value):\\n if name == \\"src\\" and value.startswith(\\"https://www.youtube.com/embed/\\"):\\n return True\\n if name in (\\"allow\\", \\"width\\", \\"height\\"):\\n return True\\n return False\\n\\n\\ndef allow_fenced_code_languages(tag, name, value):\\n return (\\n tag == \\"code\\"\\n and name == \\"class\\"\\n and value.startswith(\\"language-\\")\\n and \\" \\" not in value\\n )\\n```"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "v27nberxbjaghie3qjk6iplygy",
"model": "zeke/cog-markdown-example",
"version": "146e98d6b010c431f601ac8482d7f0f9562730c8e82f93f9ad6eff711f95023a",
"input": {
"markdown": "```py\ndef allow_iframe_youtube(tag, name, value):\n if name == \"src\" and value.startswith(\"https://www.youtube.com/embed/\"):\n return True\n if name in (\"allow\", \"width\", \"height\"):\n return True\n return False\n\n\ndef allow_fenced_code_languages(tag, name, value):\n return (\n tag == \"code\"\n and name == \"class\"\n and value.startswith(\"language-\")\n and \" \" not in value\n )\n```"
},
"logs": "",
"output": "https://replicate.delivery/mgxm/dbcf023a-1cb0-483a-84d2-2f9610effe8c/out.md",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-05-04T22:01:56.200623Z",
"started_at": "2022-05-04T22:01:59.237907Z",
"completed_at": "2022-05-04T22:01:59.237909Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/v27nberxbjaghie3qjk6iplygy/cancel",
"get": "https://api.replicate.com/v1/predictions/v27nberxbjaghie3qjk6iplygy"
},
"metrics": {
"predict_time": 0.000002,
"total_time": 3.037286
}
}