LexAmpLexAmp

Lexamp API Documentation

Overview

The Lexamp API provides programmatic access to our legal AI services. Build powerful legal applications with our OpenAI-compatible API.

Base URL

https://lexamp.net/

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

You can create and manage API keys from your Developer Dashboard.

Security Best Practices

  • Never expose API keys in client-side code or public repositories
  • Use environment variables to store keys in your applications
  • Rotate keys regularly and revoke unused ones
  • Use separate keys for development and production

Endpoints

List Models

GET /v1/models

Returns a list of available models.

Response:

{
  "object": "list",
  "data": [
    {
      "id": "legal-rag",
      "object": "model",
      "created": 1700000000,
      "owned_by": "lexamp"
    }
  ]
}

Chat Completions

POST /v1/chat/completions

Generate conversational responses with legal AI models.

Request Body:

ParameterTypeRequiredDescription
modelstringYesModel ID (use "legal-rag")
messagesarrayYesArray of message objects
temperaturenumberNoSampling temperature (0-2, default: 1.0)
top_pnumberNoNucleus sampling (0-1, default: 1.0)
nnumberNoNumber of completions (1-128, default: 1)
streambooleanNoEnable streaming (default: false)
stopstring/arrayNoStop sequences
max_tokensnumberNoMaximum tokens to generate
presence_penaltynumberNoPresence penalty (-2 to 2, default: 0)
frequency_penaltynumberNoFrequency penalty (-2 to 2, default: 0)
userstringNoUser identifier for session management

Message Object:

FieldTypeRequiredDescription
rolestringYesOne of: "system", "user", "assistant", "tool"
contentstringNoMessage content
namestringNoOptional name identifier

Example Request:

{
  "model": "legal-rag",
  "messages": [
    {"role": "system", "content": "You are a helpful legal assistant."},
    {"role": "user", "content": "What is a non-disclosure agreement?"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000
}

Response:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "legal-rag",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A non-disclosure agreement (NDA) is..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 150,
    "total_tokens": 175
  }
}

Reset Session

POST /v1/sessions/{session_id}/reset

Reset a conversation session to start fresh.

Path Parameters:

ParameterTypeDescription
session_idstringThe session identifier to reset

Response:

{
  "status": "success",
  "message": "Session abc123 reset"
}

Health Check

GET /health

Check API service health status.

Response:

{
  "status": "healthy",
  "timestamp": "2024-01-01T12:00:00Z"
}

Streaming

When stream: true is set, the API returns Server-Sent Events (SSE). Each event contains a chunk of the response:

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1700000000,"model":"legal-rag","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1700000000,"model":"legal-rag","choices":[{"index":0,"delta":{"content":"A"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","created":1700000000,"model":"legal-rag","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Pricing

ItemPrice
Input tokens$8 / million tokens
Output tokens$25 / million tokens
Legal database search$0.005 / request

Rate Limits

Rate limits vary by subscription tier:

TierRequests/minUsage
Free10100 requests/month
Starter60Pay as you go
Pro300Pay as you go
EnterpriseCustomPay as you go

Error Handling

When an error occurs, the API returns a JSON object with an error code and message:

{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "You have exceeded the rate limit.",
    "type": "rate_limit_exceeded"
  }
}

HTTP Status Codes

CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
402Payment Required - Insufficient balance
403Forbidden - Key inactive, expired, or IP not allowed
429Rate Limited - Too many requests or daily/monthly limit exceeded
500Server Error

Error Codes

CodeDescription
INVALID_API_KEYAPI key is invalid
INVALID_KEY_FORMATAPI key format is incorrect
AUTH_FAILEDAuthentication failed
KEY_INACTIVEAPI key has been deactivated
KEY_EXPIREDAPI key has expired
ACCOUNT_INACTIVEAccount is not active
PERMISSION_DENIEDAPI key lacks required permissions
IP_NOT_ALLOWEDRequest IP not in allowlist
INSUFFICIENT_BALANCEAccount balance is too low
RATE_LIMIT_EXCEEDEDPer-minute rate limit exceeded
DAILY_LIMIT_EXCEEDEDDaily request limit exceeded
MONTHLY_LIMIT_EXCEEDEDMonthly request limit exceeded

Support

For questions or issues, please contact our support team or visit the Developer Dashboard.