Skip to main content

Human feedback, structured for fine-tuning

RLHF data collection

Collect structured human feedback on your AI agent or product’s outputs — ratings, comparisons, and full sessions — directly through the ZeroDB API.

Every interaction your model produces becomes a candidate for fine-tuning data, quality monitoring, or an A/B comparison between model outputs — once a human has rated it.

/api/v1/projects/{project_id}/database/rlhf/

Log an interaction
curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/rlhf/interactions \
  -H "x-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Explain async/await in Python",
    "response": "Async/await is a syntax for writing asynchronous code...",
    "metadata": {
      "model": "qwen-coder-32b",
      "latency_ms": 840
    }
  }'
16
RLHF Endpoints
1-5
Rating Scale
1
Unified API
MCP
Compatible

A realistic end-to-end flow

Log feedback export

Log an interaction, collect feedback on it, then export the rated dataset for fine-tuning — three calls against the same API surface.

01

Log an interaction

POST a prompt/response pair (plus any metadata, like model name and latency) to /database/rlhf/interactions as your agent or product generates output.

02

Collect feedback

PUT a 1-5 rating, free-text feedback, and an optional preferred flag to /database/rlhf/interactions/{id}/feedback once a human has reviewed the interaction.

03

Export for fine-tuning

POST to /database/rlhf/export to pull your logged, rated interactions out as a dataset ready for fine-tuning or quality analysis.

Python: log → feedback → stats

rlhf_flow.py
import requests
API_KEY = "your-api-key"
PROJECT_ID = "your-project-id"
BASE = f"https://api.ainative.studio/api/v1/projects/{PROJECT_ID}/database/rlhf"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

r = requests.post(f"{BASE}/interactions", headers=headers, json={
    "prompt": "Write a Python function to sort a list",
    "response": "def sort_list(lst): return sorted(lst)",
    "metadata": {"model": "qwen-coder-32b"}
})
interaction_id = r.json()["interaction_id"]

requests.put(f"{BASE}/interactions/{interaction_id}/feedback", headers=headers, json={
    "rating": 4,
    "feedback": "Correct but could include examples",
    "preferred": True
})

stats = requests.get(f"{BASE}/stats", headers=headers).json()
print(f"Total interactions: {stats['total_interactions']}")
print(f"Average rating: {stats['avg_rating']}")

What you need to know

The facts that matter when you’re deciding whether RLHF fits your fine-tuning or quality-monitoring pipeline.

1-5 rating scale

Every piece of feedback carries an integer rating from 1 to 5, plus optional free-text feedback and a preferred flag for pairwise comparisons.

Full session lifecycle

Create a session, start it, log interactions while it runs, then stop it — sessions can also be listed, fetched, updated, and deleted.

Compare two interactions

POST two interaction IDs to /interactions/compare to capture which response a human reviewer preferred, head-to-head.

Export for fine-tuning

Pull your logged, rated interactions out in one call — the dataset that feeds fine-tuning runs and quality monitoring dashboards.

Batch logging

Log many interactions in one request via /interactions/batch instead of one HTTP call per interaction.

16 endpoints, 1 surface

Interactions, sessions, feedback, comparison, stats, and export — all under /database/rlhf/ in the same unified ZeroDB API.

The 16 endpoints, grouped

Full API reference

Interactions

  • POST/database/rlhf/interactions— log
  • POST/database/rlhf/interactions/batch— batch log
  • GET/database/rlhf/interactions— list
  • GET/database/rlhf/interactions/{id}— get
  • PUT/database/rlhf/interactions/{id}/feedback— submit feedback
  • DELETE/database/rlhf/interactions/{id}— delete
  • POST/database/rlhf/interactions/compare— compare

Sessions

  • POST/database/rlhf/sessions— create
  • GET/database/rlhf/sessions— list
  • GET/database/rlhf/sessions/{id}— get
  • PUT/database/rlhf/sessions/{id}— update
  • DELETE/database/rlhf/sessions/{id}— delete
  • POST/database/rlhf/sessions/{id}/start— start
  • POST/database/rlhf/sessions/{id}/stop— stop

Analytics

  • GET/database/rlhf/stats— stats
  • POST/database/rlhf/export— export

Why teams collect RLHF

The same logged, rated interactions serve three different jobs.

Fine-tuning data

Export rated interactions as a training dataset to fine-tune your model on the responses your reviewers actually preferred.

Quality monitoring

Pull aggregate stats — total interactions, average rating — to track whether output quality is drifting in production.

Model comparison

Use the compare endpoint to log which of two model outputs a human reviewer preferred, head-to-head.

Go deeper

This page covers the flow. The docs cover all 16 endpoints.

This overview doesn’t exhaustively document every request and response field — for the complete API reference, request schemas, and response shapes, see the real docs.