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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID (use "legal-rag") |
| messages | array | Yes | Array of message objects |
| temperature | number | No | Sampling temperature (0-2, default: 1.0) |
| top_p | number | No | Nucleus sampling (0-1, default: 1.0) |
| n | number | No | Number of completions (1-128, default: 1) |
| stream | boolean | No | Enable streaming (default: false) |
| stop | string/array | No | Stop sequences |
| max_tokens | number | No | Maximum tokens to generate |
| presence_penalty | number | No | Presence penalty (-2 to 2, default: 0) |
| frequency_penalty | number | No | Frequency penalty (-2 to 2, default: 0) |
| user | string | No | User identifier for session management |
Message Object:
| Field | Type | Required | Description |
|---|---|---|---|
| role | string | Yes | One of: "system", "user", "assistant", "tool" |
| content | string | No | Message content |
| name | string | No | Optional 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:
| Parameter | Type | Description |
|---|---|---|
| session_id | string | The 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
| Item | Price |
|---|---|
| Input tokens | $8 / million tokens |
| Output tokens | $25 / million tokens |
| Legal database search | $0.005 / request |
Rate Limits
Rate limits vary by subscription tier:
| Tier | Requests/min | Usage |
|---|---|---|
| Free | 10 | 100 requests/month |
| Starter | 60 | Pay as you go |
| Pro | 300 | Pay as you go |
| Enterprise | Custom | Pay 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
| Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 402 | Payment Required - Insufficient balance |
| 403 | Forbidden - Key inactive, expired, or IP not allowed |
| 429 | Rate Limited - Too many requests or daily/monthly limit exceeded |
| 500 | Server Error |
Error Codes
| Code | Description |
|---|---|
| INVALID_API_KEY | API key is invalid |
| INVALID_KEY_FORMAT | API key format is incorrect |
| AUTH_FAILED | Authentication failed |
| KEY_INACTIVE | API key has been deactivated |
| KEY_EXPIRED | API key has expired |
| ACCOUNT_INACTIVE | Account is not active |
| PERMISSION_DENIED | API key lacks required permissions |
| IP_NOT_ALLOWED | Request IP not in allowlist |
| INSUFFICIENT_BALANCE | Account balance is too low |
| RATE_LIMIT_EXCEEDED | Per-minute rate limit exceeded |
| DAILY_LIMIT_EXCEEDED | Daily request limit exceeded |
| MONTHLY_LIMIT_EXCEEDED | Monthly request limit exceeded |
Support
For questions or issues, please contact our support team or visit the Developer Dashboard.