Skip to content

HEDit API Reference

The HEDit API provides REST endpoints for HED annotation generation and validation.

Base URL: https://api.annotation.garden/hedit

Authentication

HEDit supports two authentication modes:

Use your own OpenRouter API key for billing control:

curl -X POST https://api.annotation.garden/hedit/annotate \
  -H "Content-Type: application/json" \
  -H "X-OpenRouter-Key: your-openrouter-key" \
  -d '{"description": "A red circle appears"}'

Use a server-provided API key:

curl -X POST https://api.annotation.garden/hedit/annotate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-server-key" \
  -d '{"description": "A red circle appears"}'

Endpoints

POST /annotate

Generate HED annotation from natural language description.

Request Body:

Bases: BaseModel

Request model for HED annotation generation.

Attributes:

Name Type Description
description str

Natural language event description to annotate

schema_version str

HED schema version to use

max_validation_attempts int

Maximum validation retry attempts

run_assessment bool

Whether to run final assessment (adds extra time)

Source code in hedit/src/api/models.py
class AnnotationRequest(BaseModel):
    """Request model for HED annotation generation.

    Attributes:
        description: Natural language event description to annotate
        schema_version: HED schema version to use
        max_validation_attempts: Maximum validation retry attempts
        run_assessment: Whether to run final assessment (adds extra time)
    """

    description: str = Field(
        ...,
        description="Natural language event description",
        min_length=1,
        examples=["A red circle appears on the left side of the screen"],
    )
    schema_version: str = Field(
        default="8.3.0",
        description="HED schema version",
        examples=["8.3.0", "8.4.0"],
    )
    max_validation_attempts: int = Field(
        default=5,
        description="Maximum validation retry attempts",
        ge=1,
        le=10,
    )
    run_assessment: bool = Field(
        default=False,
        description="Run final assessment for completeness (adds extra processing time)",
    )
Field Type Required Default Description
description string Yes - Natural language event description
schema_version string No "8.3.0" HED schema version (8.3.0, 8.4.0)
max_validation_attempts integer No 5 Max validation retries (1-10)
run_assessment boolean No false Run completeness assessment

Response:

Bases: BaseModel

Response model for HED annotation generation.

Attributes:

Name Type Description
annotation str

Generated HED annotation string

is_valid bool

Whether the annotation passed validation

is_faithful bool

Whether the annotation is faithful to description

is_complete bool

Whether the annotation is complete

validation_attempts int

Number of validation attempts made

validation_errors list[str]

List of validation errors (if any)

validation_warnings list[str]

List of validation warnings (if any)

evaluation_feedback str

Evaluation agent feedback

assessment_feedback str

Assessment agent feedback

status str

Overall workflow status

Source code in hedit/src/api/models.py
class AnnotationResponse(BaseModel):
    """Response model for HED annotation generation.

    Attributes:
        annotation: Generated HED annotation string
        is_valid: Whether the annotation passed validation
        is_faithful: Whether the annotation is faithful to description
        is_complete: Whether the annotation is complete
        validation_attempts: Number of validation attempts made
        validation_errors: List of validation errors (if any)
        validation_warnings: List of validation warnings (if any)
        evaluation_feedback: Evaluation agent feedback
        assessment_feedback: Assessment agent feedback
        status: Overall workflow status
    """

    annotation: str = Field(..., description="Generated HED annotation string")
    is_valid: bool = Field(..., description="Validation status")
    is_faithful: bool = Field(..., description="Faithfulness to original description")
    is_complete: bool = Field(..., description="Completeness status")
    validation_attempts: int = Field(..., description="Number of validation attempts")
    validation_errors: list[str] = Field(default_factory=list)
    validation_warnings: list[str] = Field(default_factory=list)
    evaluation_feedback: str = Field(default="")
    assessment_feedback: str = Field(default="")
    status: str = Field(..., description="Workflow status", examples=["success", "failed"])
Field Type Description
annotation string Generated HED annotation
is_valid boolean Validation status
is_faithful boolean Faithfulness to description
is_complete boolean Completeness status
validation_attempts integer Number of attempts made
validation_errors array List of validation errors
validation_warnings array List of validation warnings
evaluation_feedback string Evaluation agent feedback
assessment_feedback string Assessment agent feedback
status string "success" or "failed"

Example:

curl -X POST https://api.annotation.garden/hedit/annotate \
  -H "Content-Type: application/json" \
  -H "X-OpenRouter-Key: $OPENROUTER_API_KEY" \
  -d '{
    "description": "A red circle appears on the left side of the screen",
    "schema_version": "8.3.0",
    "max_validation_attempts": 5
  }'
{
  "annotation": "Sensory-event, Visual-presentation, (Red, Circle, (Left-side))",
  "is_valid": true,
  "is_faithful": true,
  "is_complete": true,
  "validation_attempts": 1,
  "validation_errors": [],
  "validation_warnings": [],
  "evaluation_feedback": "Annotation captures key visual elements...",
  "assessment_feedback": "",
  "status": "success"
}

POST /annotate-from-image

Generate HED annotation from an image.

Request Body:

Field Type Required Default Description
image string Yes - Base64 encoded image or data URI
prompt string No - Custom prompt for vision model
schema_version string No "8.4.0" HED schema version
max_validation_attempts integer No 5 Max validation retries
run_assessment boolean No false Run completeness assessment

Response:

Field Type Description
image_description string Generated description from vision model
annotation string Generated HED annotation
is_valid boolean Validation status
is_faithful boolean Faithfulness to description
is_complete boolean Completeness status
validation_attempts integer Number of attempts made
validation_errors array List of validation errors
validation_warnings array List of validation warnings
status string "success" or "failed"
image_metadata object Metadata about processed image

Example:

import base64
import httpx

# Load and encode image
with open("stimulus.png", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()

response = httpx.post(
    "https://api.annotation.garden/hedit/annotate-from-image",
    json={
        "image": f"data:image/png;base64,{image_b64}",
        "schema_version": "8.4.0"
    },
    headers={"X-OpenRouter-Key": os.environ["OPENROUTER_API_KEY"]}
)
print(response.json())

POST /validate

Validate an existing HED annotation string.

Request Body:

Field Type Required Default Description
hed_string string Yes - HED annotation to validate
schema_version string No "8.3.0" HED schema version

Response:

Field Type Description
is_valid boolean Validation status
errors array List of validation errors
warnings array List of validation warnings
parsed_string string Normalized HED string (if valid)

Example:

curl -X POST https://api.annotation.garden/hedit/validate \
  -H "Content-Type: application/json" \
  -H "X-OpenRouter-Key: $OPENROUTER_API_KEY" \
  -d '{"hed_string": "Sensory-event, Visual-presentation"}'

POST /feedback

Submit user feedback about an annotation. No authentication required.

Request Body:

Field Type Required Description
type string No Feedback type ("text" or "image")
description string No Original input description
annotation string Yes Generated HED annotation
is_valid boolean No Whether annotation was valid
user_comment string No User's comment about the annotation

Response:

Field Type Description
success boolean Whether feedback was saved
feedback_id string Unique identifier
message string Status message

GET /health

Health check endpoint.

Response:

Field Type Description
status string "healthy" or "degraded"
version string API version
llm_available boolean LLM service status
validator_available boolean Validator service status

GET /version

Get API version information.

Response:

{
  "version": "0.6.1-alpha2",
  "commit": "abc123"
}

GET /

Root endpoint with API information.

Response:

{
  "name": "HEDit API",
  "version": "0.6.1-alpha2",
  "description": "Multi-agent system for HED annotation generation",
  "endpoints": {...}
}

Error Responses

All endpoints return standard HTTP error codes:

Code Description
400 Bad Request (invalid input)
401 Unauthorized (missing or invalid API key)
500 Internal Server Error
503 Service Unavailable (workflow not initialized)

Error response format:

{
  "detail": "Error description"
}

Rate Limits

When using BYOK mode, rate limits are determined by your OpenRouter account.

OpenAPI Specification

The full OpenAPI specification is available at:

  • Swagger UI: https://api.annotation.garden/hedit/docs
  • ReDoc: https://api.annotation.garden/hedit/redoc
  • OpenAPI JSON: https://api.annotation.garden/hedit/openapi.json