Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Build, test, and deploy prompt templates on Respan. New to prompts? Start with the quickstart guide.

Prompt schema

The prompt object supports a schema_version field that controls how prompt configuration and request-body parameters are merged. Set schema_version=2 for the recommended merge behavior:
  • Prompt configuration always wins for conflicting fields (no override flag needed).
  • Uses prepend/instructions-style merging depending on the endpoint mode.
  • Supports a patch field for applying additional parameter overrides. The patch object must not contain messages or input.
Important: OpenAI SDKs strip fields like schema_version, patch, and prompt_slug during validation. Prompt schema v2 requires raw HTTP requests (e.g., requests in Python or fetch in TypeScript).
import requests

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_RESPAN_API_KEY',
}

data = {
    'prompt': {
        'prompt_id': 'YOUR_PROMPT_ID',
        'schema_version': 2,
        'variables': {
            'task_description': 'Square a number',
        },
        'patch': {
            'temperature': 0.9,
            'max_tokens': 500
        }
    }
}

response = requests.post(
    'https://api.respan.ai/api/chat/completions',
    headers=headers,
    json=data
)
print(response.json())

Prompt schema v1 (default, legacy)

When schema_version is absent or 1, merging is controlled by the override flag:
  • override=true: prompt configuration wins for all conflicting fields.
  • override=false (default): request body wins for conflicting fields.
request_body = {
    "prompt": {
        "prompt_id": "042f5f",
        "override": True,
        "override_params": {
            "temperature": 0.8,
            "max_tokens": 150,
            "model": "gpt-4o"
        }
    }
}
Append new messages to the end of existing prompt messages:
request_body = {
    "prompt": {
        "prompt_id": "042f5f",
        "override_config": {"messages_override_mode": "append"},
        "override_params": {"messages": [{"role": "user", "content": "Additional context"}]},
    }
}
Replace all existing prompt messages:
request_body = {
    "prompt": {
        "prompt_id": "042f5f",
        "override_config": {"messages_override_mode": "override"},
        "override_params": {"messages": [{"role": "user", "content": "Completely new conversation"}]},
    }
}

Variables

Use {{variable_name}} syntax to add dynamic content to your prompts. Variables let you reuse the same template across different inputs — pass values at runtime from code, or fill them from testset columns in experiments. See the quickstart for setup and basic usage.

Jinja templates

Respan supports Jinja templates for conditionals, filters, and JSON input access.
Jinja support
FeatureSyntaxExample
Conditionals{% if %}...{% endif %}{% if condition %}{{ variable_name }}{% endif %}
JSON inputs{{ input.key }}{{ input.name }}
Filters{{ var | filter }}{{ variable_name | filter_name }}
Comments{# ... #}{# This is a comment #}
See the Filters in Jinja templates guide for details. You can also set default variable values when creating a version via the API:
data = {
    "messages": [
        {"role": "system", "content": "You are a helpful {{role}}."},
        {"role": "user", "content": "Help me with {{task_description}}."}
    ],
    "model": "gpt-4o-mini",
    "variables": {
        "role": "assistant",
        "task_description": "sorting an array"
    },
}

Prompt composition

Prompt composition lets a variable in one prompt reference another prompt. At request time, the child is rendered first, converted to plain text, and inserted into the parent variable. To use prompt composition, create two prompts: a child prompt and a parent prompt that has a {{variable}} where the child’s output will be injected.
1

Configure the variable

In the parent prompt editor:
  • Open the Variables panel on the right side
  • Find the variable you want to embed a prompt into
  • Change its type from Text to Prompt
  • Select the child prompt
  • Fill in all the child’s variables
Prompt composition setup
2

Run your prompt

Click Run to test. The child prompt is rendered first, converted to plain text, and injected into the parent variable before the LLM sees it.
Limits:
  • Circular references are rejected (HTTP 400).
  • Maximum prompt-chain depth is 2 (parent → child is safest). Exceeding this returns HTTP 400.

Structured output

Define structured output using JSON schema to ensure AI responses follow a specific format, following the OpenAI Structured Outputs specification.
Configure JSON schema in the prompt editor or the playground:
JSON schema in prompt editor
JSON schema in playground
You can generate schemas using the AI generator or browse examples in the editor.
AI schema generator

Streaming

Enable streaming in the prompt settings sidebar. After enabling, commit and deploy the prompt.
Streaming
If you use a prompt with streaming enabled, you must also set stream=True in your SDK call:
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role":"user", "content":"Tell me a long story"}],
    stream=True,
    extra_body={
      "prompt": {
          "prompt_id": "YOUR_PROMPT_ID",
          "variables": {"variable_name": "variable_value"},
        }
    }
)

Deployment & versioning

Commit saves a new version of your prompt. Deploy makes a version live for production traffic.View version history in the Overview panel, or click Version in the Editor for detailed diffs.
Version history
Click on each version to see the diff of changes.
Track changes
To deploy, go to the Deployments tab and click Deploy.
Deploy prompt
To rollback, deploy an earlier version from the Deployments tab.

Playground

Test and iterate on prompts in the Prompt Playground.
From the prompt editor, enter variable values and click Playground in the top bar to test. Click Commit to save changes back to your prompt library.
Bring prompt to playground
You can also debug production logs by clicking Open in Playground on any log entry.
Debug from logs
Set the number of variants in the side panel to generate multiple responses and compare them in the Variants tab.
Set variants

Prompt logging

Log prompt usage to track performance metrics, compare versions, and analyze request distribution.
import requests

url = "https://api.respan.ai/api/request-logs/create/"
payload = {
    "model": "claude-3-5-sonnet-20240620",
    "completion_message": {
        "role": "assistant",
        "content": "Hi, how can I assist you today?"
    },
    "prompt": {
        "prompt_id": "xxxxxx",
        "variables": {
            "task_description": "Square a number",
            "specific_library": "math"
        },
    },
    "generation_time": 5.7,
    "ttft": 3.1,
}
headers = {
    "Authorization": "Bearer YOUR_RESPAN_API_KEY",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json=payload)
Filter logs by prompt name on the Logs page.
Prompt logs

Team collaboration

  • Share — click the Link button in the Editor to share a prompt
  • Comments — add comments to discuss changes
  • Labels — categorize and organize prompts
Share prompt

Parameters reference

prompt_id
string
required
The unique identifier of your saved prompt template.
variables
object
Variables to inject into your prompt template. Values can be strings or typed prompt objects for composition.
{
  "variables": {
    "user_name": "John",
    "task": "summarize"
  }
}
override
boolean
default:false
When true, the saved prompt configuration overrides SDK parameters like model and messages.
override_params
object
Parameters that override your saved prompt configuration (temperature, max_tokens, messages, model, etc.).
override_config
object
Controls how override parameters are applied.
  • messages_override_mode: "append" (add to existing) or "override" (replace all)
schema_version
integer
default:1
Controls the prompt merge strategy. 1 (default, legacy) uses override flag logic. 2 (recommended) uses prepend/instructions-style merging where the prompt config always wins. See Prompt schema.
patch
object
Additional parameter overrides applied in v2 mode (schema_version=2). Must not contain messages or input. Useful for overriding fields like temperature or max_tokens while letting the prompt config control messages and model.
echo
boolean
default:false
When enabled, the response includes the final prompt messages used.
version
integer | string
Pin a specific prompt version. Omit for deployed version, use "latest" for newest draft.