Skip to main content
POST
/
v2
/
prompts
Create a prompt
curl --request POST \
  --url https://api.arize.com/v2/prompts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "space_id": "U3BhY2U6MTIzOmFiY2Q=",
  "name": "My Prompt",
  "description": "A helpful assistant prompt",
  "version": {
    "commit_message": "Initial version",
    "input_variable_format": "f_string",
    "provider": "open_ai",
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello, {name}!"
      }
    ]
  }
}
'
import requests

url = "https://api.arize.com/v2/prompts"

payload = {
"space_id": "U3BhY2U6MTIzOmFiY2Q=",
"name": "My Prompt",
"description": "A helpful assistant prompt",
"version": {
"commit_message": "Initial version",
"input_variable_format": "f_string",
"provider": "open_ai",
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, {name}!"
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
space_id: 'U3BhY2U6MTIzOmFiY2Q=',
name: 'My Prompt',
description: 'A helpful assistant prompt',
version: {
commit_message: 'Initial version',
input_variable_format: 'f_string',
provider: 'open_ai',
model: 'gpt-4',
messages: [
{role: 'system', content: 'You are a helpful assistant.'},
{role: 'user', content: 'Hello, {name}!'}
]
}
})
};

fetch('https://api.arize.com/v2/prompts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.arize.com/v2/prompts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'space_id' => 'U3BhY2U6MTIzOmFiY2Q=',
'name' => 'My Prompt',
'description' => 'A helpful assistant prompt',
'version' => [
'commit_message' => 'Initial version',
'input_variable_format' => 'f_string',
'provider' => 'open_ai',
'model' => 'gpt-4',
'messages' => [
[
'role' => 'system',
'content' => 'You are a helpful assistant.'
],
[
'role' => 'user',
'content' => 'Hello, {name}!'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.arize.com/v2/prompts"

payload := strings.NewReader("{\n \"space_id\": \"U3BhY2U6MTIzOmFiY2Q=\",\n \"name\": \"My Prompt\",\n \"description\": \"A helpful assistant prompt\",\n \"version\": {\n \"commit_message\": \"Initial version\",\n \"input_variable_format\": \"f_string\",\n \"provider\": \"open_ai\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, {name}!\"\n }\n ]\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.arize.com/v2/prompts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"space_id\": \"U3BhY2U6MTIzOmFiY2Q=\",\n \"name\": \"My Prompt\",\n \"description\": \"A helpful assistant prompt\",\n \"version\": {\n \"commit_message\": \"Initial version\",\n \"input_variable_format\": \"f_string\",\n \"provider\": \"open_ai\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, {name}!\"\n }\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.arize.com/v2/prompts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"space_id\": \"U3BhY2U6MTIzOmFiY2Q=\",\n \"name\": \"My Prompt\",\n \"description\": \"A helpful assistant prompt\",\n \"version\": {\n \"commit_message\": \"Initial version\",\n \"input_variable_format\": \"f_string\",\n \"provider\": \"open_ai\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello, {name}!\"\n }\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "prompt_001",
  "name": "My Prompt",
  "description": "A prompt for customer support",
  "space_id": "space_12345",
  "created_at": "2024-01-01T12:00:00Z",
  "updated_at": "2024-01-02T12:00:00Z",
  "created_by_user_id": "user_12345",
  "version": {
    "id": "pv_001",
    "prompt_id": "prompt_001",
    "commit_hash": "abc123def456",
    "commit_message": "Initial version",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello, {name}!"
      }
    ],
    "input_variable_format": "f_string",
    "provider": "open_ai",
    "model": "gpt-4",
    "invocation_params": {},
    "provider_params": {},
    "created_at": "2024-01-01T12:00:00Z",
    "created_by_user_id": "user_12345",
    "labels": []
  }
}
{
"status": 400,
"title": "Invalid request parameters",
"detail": "The 'name' field is required and must be a non-empty string.",
"instance": "/resource",
"type": "https://arize.com/docs/ax/rest-reference/errors#invalid-request"
}
{
"status": 401,
"title": "Authentication required",
"detail": "You must be authenticated to access this resource.",
"instance": "/resource",
"type": "https://arize.com/docs/ax/rest-reference/errors#authentication-required"
}
{
"status": 403,
"title": "Access forbidden",
"detail": "You do not have permission to access this resource.",
"instance": "/resource/12345",
"type": "https://arize.com/docs/ax/rest-reference/errors#access-forbidden"
}
{
"status": 409,
"title": "Resource conflict",
"detail": "A resource with the given identifier already exists.",
"instance": "/resource",
"type": "https://arize.com/docs/ax/rest-reference/errors#resource-conflict"
}
{
"status": 422,
"title": "Unprocessable Entity",
"detail": "One or more fields failed validation.",
"instance": "/resource/12345",
"type": "https://arize.com/docs/ax/rest-reference/errors#unprocessable-entity"
}
{
"status": 429,
"title": "Rate limit exceeded",
"detail": "You have exceeded the allowed number of requests. Please try again later.",
"instance": "/resource",
"type": "https://arize.com/docs/ax/rest-reference/errors#rate-limit-exceeded"
}

Authorizations

Authorization
string
header
required

Most Arize AI endpoints require authentication. For those endpoints that require authentication, include your API key in the request header using the format

Body

application/json

Body containing prompt creation parameters with an initial version

space_id
string
required

ID of the space to create the prompt in

name
string
required

Name of the prompt (must be unique within the space)

version
object
required

Initial version configuration for a new prompt

description
string

Description of the prompt. Optional. If omitted, the prompt has no description.

Response

A prompt object with a resolved version

A prompt with a resolved version. Returned by Create Prompt and Get Prompt. The version is the initial version on create, or the resolved version (latest, by ID, or by label) on get.

id
string
required

The prompt ID

name
string
required

The prompt name

space_id
string
required

The space ID the prompt belongs to

created_at
string<date-time>
required

When the prompt was created

updated_at
string<date-time>
required

When the prompt was last updated

created_by_user_id
string
required

The user ID of the user who created the prompt

version
object
required

A prompt version represents a specific snapshot of a prompt's configuration. Each version captures the messages, model settings, and parameters at a point in time. Versions are immutable once created and are identified by a commit hash.

description
string | null

The prompt description