GALENAPI

Building with AI Agents

Connect Galen to your AI agent via tool-use, function calling, or MCP.

Discovery

Galen publishes llms.txt at the root of the developer portal for AI agent discovery. This follows the llms.txt standard and provides a concise summary of available API capabilities.

A full reference is available at /llms-full.txt for agents that need complete endpoint documentation in a single file.

# Concise overview for agent discovery
https://developer.usegalen.com/llms.txt

# Full reference with all endpoints and schemas
https://developer.usegalen.com/llms-full.txt

Structured Responses

All Galen endpoints return structured JSON with consistent schemas, making responses ideal for tool-use with no parsing needed.

Every entity includes entity_type, name, and evidence_tier. Relationships include source, target, relationship_type, and provenance.

OpenAI Function Calling

Define a tool that wraps Galen entity search, then let the model decide when to call it.

{
  "name": "galen_entity_search",
  "description": "Search the Galen cancer knowledge graph for entities by name",
  "parameters": {
    "type": "object",
    "properties": {
      "query": { "type": "string", "description": "Entity name or keyword" }
    },
    "required": ["query"]
  }
}
import requests

def galen_entity_search(query: str) -> dict:
    response = requests.get(
        f"https://research.usegalen.com/api/v1/entities/search",
        params={"q": query},
        headers={"X-API-Key": API_KEY}
    )
    return response.json()

Claude Tool Use

Anthropic's tool_use format works naturally with Galen's causal intervention endpoint. Define the tool schema and Claude will call it when reasoning about biological mechanisms.

tools = [{
    "name": "galen_causal_intervention",
    "description": "Simulate inhibiting or activating a biological target and trace downstream causal effects",
    "input_schema": {
        "type": "object",
        "properties": {
            "target": {"type": "string", "description": "Gene or protein to intervene on"},
            "intervention_type": {"type": "string", "enum": ["inhibit", "activate"]}
        },
        "required": ["target", "intervention_type"]
    }
}]

Best Practices

  • Resolve names first. Use entity search to resolve names before querying relationships or running causal interventions. Names are case-insensitive, but exact matches are faster.
  • Cache entity lookups. The knowledge graph is updated daily, not in real-time. Caching entity responses for minutes or hours is safe and reduces latency.
  • Handle rate limits. Use exponential backoff when you receive a 429 response. The Retry-After header tells you how long to wait.
  • Use the OpenAPI spec. The full schema is available at /openapi.json for auto-generating client code or feeding to agents that support schema-driven tools.