Appearance
Creating an API Key
To start using the PromptChainer API, you'll first need to generate an API key. Follow the steps below to create your API key:
- Log in or sign up: If you haven't already, log in to your PromptChainer account or sign up for a new account.
- Navigate to the API Keys section: Once logged in, click on the
API Keys
tab in the main navigation menu. - Generate a new API key: Click the
Create API Key
button. A new API key will be created and displayed on the screen. - Copy and save your API key: Make sure to copy the API key and store it in a secure location. You'll need to use this key to authenticate your requests to the PromptChainer API.
Important: Treat your API key like a password. Keep it secret and never share it publicly. If you believe your API key has been compromised, you can regenerate a new one following the same steps.
Now that you have your API key, you're ready to start using the PromptChainer API!
Authenticating Requests
To authenticate your requests to the PromptChainer API, you'll need to include your API key in the x-api-key
header of your request. For example:
http
POST /api/flows/run/clibnwpno000bmc0k9hvv3y7f HTTP/1.1
x-api-key: 7341ec8f-ba13-48f1-985a-db90896eff7f
Content-Type: application/json
Host: api.promptchainer.io
{
"variables": {
"item": "cat",
"color": "green"
}
}
bash
curl -X POST \
'https://api.promptchainer.io/api/flows/run/clibnwpno000bmc0k9hvv3y7f' \
--header 'x-api-key: 7341ec8f-ba13-48f1-985a-db90896eff7f' \
--header 'Content-Type: application/json' \
--data-raw '{
"variables": {
"item": "cat",
"color": "green"
}
}'
ts
import fetch from 'node-fetch'
const doRequest = async () => {
const api_key = 'ec295114-80b6-41e0-8575-abf4e4e86a4a';
const flow_id = 'cliebwpno000acc0k9hvv3yem';
const url = `https://api.promptchainer.io/api/flows/run/${flow_id}`;
const data = {
variables: {
color: 'green',
item: 'cat'
}
}
const request = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': "application/json",
'x-api-key': api_key
},
body: JSON.stringify(data)
})
const response = await request.json()
console.log('response', response)
return response
}
doRequest()
json
{
"nodes": [
{
"type": "variableNode",
"position": {
"x": 1268,
"y": 633
},
"data": {
"variable": {
"label": "color",
"value": "Blue"
}
},
"connectable": true,
"dragging": false,
"id": "d2f04675-b516-49f0-8b37-4d323fe6737d",
"width": 260,
"height": 146
},
{
"type": "variableNode",
"position": {
"x": 1269,
"y": 824
},
"data": {
"variable": {
"label": "item",
"value": "Ball"
}
},
"connectable": true,
"dragging": false,
"id": "fe4ba672-1b7f-4e10-a66d-51ef38d49562",
"width": 260,
"height": 146,
"selected": false,
"positionAbsolute": {
"x": 1269,
"y": 824
}
},
{
"type": "imageNode",
"position": {
"x": 1669,
"y": 547
},
"data": {
"name": "img",
"variables": [
{
"id": "d2f04675-b516-49f0-8b37-4d323fe6737d",
"label": "color",
"value": "Blue"
},
{
"id": "fe4ba672-1b7f-4e10-a66d-51ef38d49562",
"label": "item",
"value": "Ball"
}
],
"modelParams": {
"model": "dall-e"
},
"prompt": "A picture of a {color} and big {item}",
"output": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-uR199VMx5csiMWN0ett3qiZC/user-HqsqjutgGORv3O8OsBOARVvy/img-jW9oxzX3pUKA3dmO7MriOiSd.png?st=2023-05-31T11%3A08%3A55Z&se=2023-05-31T13%3A08%3A55Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-05-30T20%3A17%3A57Z&ske=2023-05-31T20%3A17%3A57Z&sks=b&skv=2021-08-06&sig=LZRCEQJp3hEzEp1SXJ5bxI1JrBa6PunwJJto7xGiHbU%3D",
"lastRundate": "2023-05-31T12:08:55.598Z"
},
"connectable": true,
"dragging": false,
"id": "e7c5aba3-3d57-4ce8-81b8-04404c6d391a",
"width": 271,
"height": 1019,
"selected": false,
"positionAbsolute": {
"x": 1669,
"y": 547
}
},
{
"type": "outputNode",
"position": {
"x": 2078,
"y": 660
},
"data": {
"name": "image",
"output": {
"e7c5aba3-3d57-4ce8-81b8-04404c6d391a": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-uR199VMx5csiMWN0ett3qiZC/user-HqsqjutgGORv3O8OsBOARVvy/img-jW9oxzX3pUKA3dmO7MriOiSd.png?st=2023-05-31T11%3A08%3A55Z&se=2023-05-31T13%3A08%3A55Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-05-30T20%3A17%3A57Z&ske=2023-05-31T20%3A17%3A57Z&sks=b&skv=2021-08-06&sig=LZRCEQJp3hEzEp1SXJ5bxI1JrBa6PunwJJto7xGiHbU%3D"
}
},
"connectable": true,
"dragging": false,
"id": "068ba195-8880-4a7e-99e3-6f9331462722",
"width": 271,
"height": 460,
"selected": false,
"positionAbsolute": {
"x": 2078,
"y": 660
}
},
{
"type": "actionNode",
"position": {
"x": 2370.04377754738,
"y": 662.4354789633089
},
"data": {
"name": "joke",
"variables": [
{
"id": "d2f04675-b516-49f0-8b37-4d323fe6737d",
"label": "color",
"value": "Blue"
},
{
"id": "fe4ba672-1b7f-4e10-a66d-51ef38d49562",
"label": "item",
"value": "Ball"
}
],
"modelParams": {
"model": "text-davinci-003",
"temperature": 0.7,
"max_tokens": 2500,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"n": 1,
"best_of": 1
},
"prompt": "A joke about a {color} and big {item}",
"output": ""
},
"connectable": true,
"dragging": false,
"id": "3fff0dbb-7784-41ba-889b-9988d3a3c5d2",
"width": 218,
"height": 342,
"selected": false,
"positionAbsolute": {
"x": 2370.04377754738,
"y": 662.4354789633089
}
},
{
"type": "outputNode",
"position": {
"x": 2378.784624936171,
"y": 1013.0405797803693
},
"data": {
"name": "text",
"output": {
"3fff0dbb-7784-41ba-889b-9988d3a3c5d2": ""
}
},
"connectable": true,
"dragging": false,
"id": "846b3bef-15c6-434f-9a38-fa5f26bb635c",
"width": 260,
"height": 100,
"selected": true,
"positionAbsolute": {
"x": 2378.784624936171,
"y": 1013.0405797803693
}
}
],
"edges": [
{
"source": "fe4ba672-1b7f-4e10-a66d-51ef38d49562",
"sourceHandle": "output",
"target": "e7c5aba3-3d57-4ce8-81b8-04404c6d391a",
"targetHandle": "variables",
"id": "reactflow__edge-fe4ba672-1b7f-4e10-a66d-51ef38d49562output-e7c5aba3-3d57-4ce8-81b8-04404c6d391avariables"
},
{
"source": "d2f04675-b516-49f0-8b37-4d323fe6737d",
"sourceHandle": "output",
"target": "e7c5aba3-3d57-4ce8-81b8-04404c6d391a",
"targetHandle": "variables",
"id": "reactflow__edge-d2f04675-b516-49f0-8b37-4d323fe6737doutput-e7c5aba3-3d57-4ce8-81b8-04404c6d391avariables"
},
{
"source": "e7c5aba3-3d57-4ce8-81b8-04404c6d391a",
"sourceHandle": "output",
"target": "068ba195-8880-4a7e-99e3-6f9331462722",
"targetHandle": "input",
"id": "reactflow__edge-e7c5aba3-3d57-4ce8-81b8-04404c6d391aoutput-068ba195-8880-4a7e-99e3-6f9331462722input"
},
{
"source": "d2f04675-b516-49f0-8b37-4d323fe6737d",
"sourceHandle": "output",
"target": "3fff0dbb-7784-41ba-889b-9988d3a3c5d2",
"targetHandle": "variables",
"id": "reactflow__edge-d2f04675-b516-49f0-8b37-4d323fe6737doutput-3fff0dbb-7784-41ba-889b-9988d3a3c5d2variables"
},
{
"source": "fe4ba672-1b7f-4e10-a66d-51ef38d49562",
"sourceHandle": "output",
"target": "3fff0dbb-7784-41ba-889b-9988d3a3c5d2",
"targetHandle": "variables",
"id": "reactflow__edge-fe4ba672-1b7f-4e10-a66d-51ef38d49562output-3fff0dbb-7784-41ba-889b-9988d3a3c5d2variables"
},
{
"source": "3fff0dbb-7784-41ba-889b-9988d3a3c5d2",
"sourceHandle": "output",
"target": "846b3bef-15c6-434f-9a38-fa5f26bb635c",
"targetHandle": "input",
"id": "reactflow__edge-3fff0dbb-7784-41ba-889b-9988d3a3c5d2output-846b3bef-15c6-434f-9a38-fa5f26bb635cinput"
}
]
}
Response
json
[
{
"name": "image",
"output": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-uR199VMx5csiMWN0ett3qiZC/user-HqsqjutgGORv3O8OsBOARVvy/img-JJQcQcpsqvZ9XGDGyaUATyZC.png?st=2023-05-31T12%3A35%3A25Z&se=2023-05-31T14%3A35%3A25Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-05-30T20%3A17%3A12Z&ske=2023-05-31T20%3A17%3A12Z&sks=b&skv=2021-08-06&sig=/7zEtZsMDucfbXLhZJg472uucvXpzcLkv89Ubu%2BCChU%3D",
"type": "output"
},
{
"name": "text",
"output": "\n\nQ: What do you call a green and big cat?\nA: A Meanie Meaneron!",
"type": "output"
}
]