Skip to main content

Building with AI Agents

The Court Rules Linter API is designed to work well with AI agents. The OpenAPI spec provides everything an LLM needs to understand and call the API.

Step 1: Download the OpenAPI spec

The spec is available as a live endpoint:
curl 'https://api.courtrules.app/api/v1/openapi.yaml' \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o openapi.yaml
This returns the complete OpenAPI 3.1 specification with all endpoints, request/response schemas, and examples.

Step 2: Feed the spec to your agent

Give the OpenAPI spec to your LLM as context. Most AI agent frameworks support this natively:
  • Claude: Attach the YAML file as context or paste it into the system prompt
  • ChatGPT: Upload the file or use the Actions/Functions feature
  • LangChain / LlamaIndex: Use their OpenAPI tool loader
  • Custom agents: Parse the spec and register each endpoint as a tool

Step 3: Example agent prompt

Here’s a system prompt that turns an LLM into a court rules compliance assistant:
You are a federal court filing compliance assistant. You have access to
the Court Rules Linter API.

When the user describes a document they plan to file, do the following:

1. Ask for the judge name (or slug), district, document type, and
   motion type if not provided.
2. Call GET /api/v1/rules to show the user what rules apply BEFORE
   they finalize their document.
3. Once they have page count and word count, call POST /api/v1/check
   to run the compliance check.
4. Explain each result in plain English. For FAIL results, state
   exactly what needs to change and cite the rule source.
5. For ACTION_REQUIRED items, explain what the filer needs to do
   (e.g., prepare courtesy copies, complete a pre-motion conference).

Always cite the rule source (e.g., "FRCP 10(a)", "EDNY LR 7.1(c)",
"Amon SO") when explaining a result.

If the user provides raw document text instead of metadata, call
POST /api/v1/classify first to analyze the document, then use the
check_request from the response to call POST /api/v1/check.

Tips for agent builders

Use /rules for context

Before running a compliance check, call /rules to give your agent (and the user) full context on what rules apply. This makes the agent’s explanations more informed:
# Get all rules for a judge + document context
curl 'https://api.courtrules.app/api/v1/rules?judge_slug=carol-bagley-amon&district_id=edny&document_scope=brief_support&motion_type=Rule_56' \
  -H "Authorization: Bearer YOUR_API_KEY"

Use /check for validation

The check endpoint is deterministic and sub-millisecond. Your agent can call it multiple times as the user iterates on their document without performance concerns:
# Check compliance -- fast, deterministic, idempotent
curl -X POST https://api.courtrules.app/api/v1/check \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "judge_slug": "carol-bagley-amon",
    "district_id": "edny",
    "document_scope": "brief_support",
    "motion_type": "Rule_56",
    "document": { "page_count": 22, "word_count": 7200 }
  }'

Use /classify for document preprocessing

If the user provides raw text (pasted from a document, extracted from a PDF), use /classify to analyze it before checking:
# Classify raw text -- LLM-powered, 5-15s
curl -X POST https://api.courtrules.app/api/v1/classify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "judge_slug": "carol-bagley-amon",
    "district_id": "edny",
    "text": "MEMORANDUM OF LAW IN SUPPORT OF MOTION FOR SUMMARY JUDGMENT..."
  }'
The response includes a check_request field that can be passed directly to /check.

Use /courts for discovery

Let the agent browse available courts and judges:
# List all courts
curl 'https://api.courtrules.app/api/v1/courts' \
  -H "Authorization: Bearer YOUR_API_KEY"

# List judges in a district
curl 'https://api.courtrules.app/api/v1/judges?district_id=edny' \
  -H "Authorization: Bearer YOUR_API_KEY"

Example conversation flow

User:  I'm filing a summary judgment motion with Judge Brown in EDNY.
       My brief is 22 pages and about 7,200 words.

Agent: Let me check that against Judge Brown's requirements.
       [calls POST /check with page_count=22, word_count=7200]

       Your filing is NON-COMPLIANT. Here's what I found:

       FAIL: 22 pages exceeds Judge Brown's 20-page limit
       (Source: Brown SO section 2.B)

       You need to cut 2 pages. Judge Brown's standing order
       limits support briefs to 20 pages.

       Also note:
       - Courtesy copies are always required (Brown SO section 1)
       - Motion papers must NOT be filed until fully briefed
         (Brown SO section 3.B)

User:  What if I was filing with Judge Amon instead?

Agent: [calls POST /check with judge_slug=carol-bagley-amon]

       With Judge Amon, the same document gets a different result:
       no page limit violation. Judge Amon doesn't impose a
       judge-specific page limit on briefs.

       However, you'd still need:
       - Courtesy copies: tabbed binder, double-sided (Amon SO)
       - Wait for full briefing before filing (Amon SO)

Framework-specific examples

Claude tool use

{
  "name": "check_court_compliance",
  "description": "Check a legal document for compliance with federal court rules",
  "input_schema": {
    "type": "object",
    "properties": {
      "judge_slug": { "type": "string" },
      "district_id": { "type": "string" },
      "document_scope": { "type": "string" },
      "motion_type": { "type": "string" },
      "page_count": { "type": "integer" },
      "word_count": { "type": "integer" }
    },
    "required": ["judge_slug", "district_id", "document_scope", "page_count", "word_count"]
  }
}

OpenAI function calling

{
  "type": "function",
  "function": {
    "name": "check_court_compliance",
    "description": "Check a legal document for compliance with federal court rules",
    "parameters": {
      "type": "object",
      "properties": {
        "judge_slug": { "type": "string", "description": "Judge identifier slug" },
        "district_id": { "type": "string", "description": "Federal district ID" },
        "document_scope": {
          "type": "string",
          "enum": ["brief_support", "brief_reply", "brief_opposition", "letter", "discovery_letter"]
        },
        "motion_type": {
          "type": "string",
          "enum": ["Rule_12", "Rule_56", "Rule_50", "Rule_59", "discovery", "general"]
        },
        "page_count": { "type": "integer" },
        "word_count": { "type": "integer" }
      },
      "required": ["judge_slug", "district_id", "document_scope", "page_count", "word_count"]
    }
  }
}