Skip to content

Çalışma Alanı Bilgi İstemi Laboratuvarı

Tutarlı yapay zeka etkileşimleri için bilgi istemi şablonları oluşturun, test edin ve yayınlayın.

Uç noktalar

MethodPathDescriptionAuthRate Limit
GET/workspaces/:workspaceId/ai/prompt-lab/templatesList templatesJWT + Entitlement60/min
POST/workspaces/:workspaceId/ai/prompt-lab/templatesCreate a templateJWT + Entitlement10/min
POST/workspaces/:workspaceId/ai/prompt-lab/templates/:templateId/testTest a templateJWT + Entitlement20/min
POST/workspaces/:workspaceId/ai/prompt-lab/templates/:templateId/publishPublish a templateJWT + Entitlement10/min

Şablon Oluştur

Rica etmek

Talep Gövdesi

FieldTypeRequiredDescription
namestringYesTemplate name
templatestringYesPrompt template with placeholders
variablesstring[]NoList of variable names used in the template

Cevap

Yanıt Örneği

json
{
  "data": {
    "id": "cm5prompt01",
    "workspaceId": "cm5ws01",
    "name": "Chain Review Prompt",
    "template": "Analyze the following chain data...",
    "variables": ["chainName", "currentStreak", "completionRate"],
    "status": "draft",
    "createdAt": "2026-03-17T10:00:00.000Z"
  }
}

Kod Örnekleri

Çalışma alanının "kimliğini" "$WORKSPACE_ID" olarak kullanın.

bash
curl -X POST https://api.chainabit.com/api/v1/workspaces/$WORKSPACE_ID/ai/prompt-lab/templates \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Chain Review Prompt",
    "template": "Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
    "variables": ["chainName", "currentStreak", "completionRate"]
  }'
javascript
const BASE_URL = process.env.BASE_URL;
const TOKEN = process.env.TOKEN;
const workspaceId = process.env.WORKSPACE_ID;

const response = await fetch(
  `${BASE_URL}/workspaces/${workspaceId}/ai/prompt-lab/templates`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      name: "Chain Review Prompt",
      template:
        "Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
      variables: ["chainName", "currentStreak", "completionRate"],
    }),
  }
);
const { data } = await response.json();
python
import requests, os

workspace_id = os.environ["WORKSPACE_ID"]
response = requests.post(
    f"{os.environ['BASE_URL']}/workspaces/{workspace_id}/ai/prompt-lab/templates",
    headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
    json={
        "name": "Chain Review Prompt",
        "template": "Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
        "variables": ["chainName", "currentStreak", "completionRate"],
    },
)
data = response.json()["data"]

Test Şablonu

Rica etmek

  • Yol parametreleri: workspaceId, templateId
  • Gövde: değişkenler — şablonun yer tutucuları için değerler

Cevap

json
{
  "data": {
    "renderedPrompt": "Analyze the following chain data:\n\nChain: Daily Vocabulary Practice\nStreak: 5 days\nCompletion Rate: 85%\n\nProvide 3 specific recommendations.",
    "response": "Here are 3 recommendations for your Daily Vocabulary Practice chain...",
    "tokensUsed": 450,
    "latencyMs": 1800
  }
}

Kod Örnekleri

Create Template'in yanıtındaki ("data.id") "id"yi "$TEMPLATE_ID" olarak kullanın.

bash
curl -X POST https://api.chainabit.com/api/v1/workspaces/$WORKSPACE_ID/ai/prompt-lab/templates/$TEMPLATE_ID/test \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "chainName": "Daily Vocabulary Practice",
      "currentStreak": 5,
      "completionRate": 85
    }
  }'
javascript
const BASE_URL = process.env.BASE_URL;
const TOKEN = process.env.TOKEN;
const workspaceId = process.env.WORKSPACE_ID;
const templateId = process.env.TEMPLATE_ID; // from Create Template's response

const response = await fetch(
  `${BASE_URL}/workspaces/${workspaceId}/ai/prompt-lab/templates/${templateId}/test`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      variables: {
        chainName: "Daily Vocabulary Practice",
        currentStreak: 5,
        completionRate: 85,
      },
    }),
  }
);
const { data } = await response.json();
python
import requests, os

workspace_id = os.environ["WORKSPACE_ID"]
template_id = os.environ["TEMPLATE_ID"]  # from Create Template's response
response = requests.post(
    f"{os.environ['BASE_URL']}/workspaces/{workspace_id}/ai/prompt-lab/templates/{template_id}/test",
    headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
    json={"variables": {"chainName": "Daily Vocabulary Practice", "currentStreak": 5, "completionRate": 85}},
)
data = response.json()["data"]

Built with purpose.