POST
/
api
/
v1
/
chat
/
completions
curl -X POST "https://ai.costa.app/api/v1/chat/completions" \
  -H "Authorization: Bearer costa_ent_your_key_here" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: https://docs.costa.app" \
  -H "X-Title: Costa AI Documentation Test" \
  -d '{
    "model": "costa/enterprise-coder-v1",
    "messages": [
      {
        "role": "user",
        "content": "Write a secure Python function to hash passwords"
      }
    ],
    "max_tokens": 300,
    "temperature": 0.1,
    "security_level": "high"
  }'
{
  "id": "chatcmpl-costa-123456789",
  "object": "chat.completion",
  "created": 1704067200,
  "model": "costa/enterprise-coder-v1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here's a secure Python function to hash passwords using bcrypt:\n\n```python\nimport bcrypt\n\ndef hash_password(password: str) -> str:\n    \"\"\"\n    Securely hash a password using bcrypt with salt.\n    \n    Args:\n        password (str): The plain text password to hash\n        \n    Returns:\n        str: The hashed password\n    \"\"\"\n    # Generate salt and hash password\n    salt = bcrypt.gensalt(rounds=12)\n    hashed = bcrypt.hashpw(password.encode('utf-8'), salt)\n    return hashed.decode('utf-8')\n\ndef verify_password(password: str, hashed: str) -> bool:\n    \"\"\"\n    Verify a password against its hash.\n    \n    Args:\n        password (str): Plain text password\n        hashed (str): Hashed password to verify against\n        \n    Returns:\n        bool: True if password matches, False otherwise\n    \"\"\"\n    return bcrypt.checkpw(password.encode('utf-8'), hashed.encode('utf-8'))\n```\n\nThis implementation uses bcrypt with 12 rounds for strong security."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 245,
    "total_tokens": 257,
    "cost_usd": 0.00385
  },
  "security": {
    "level": "high",
    "data_residency": "us-east",
    "audit_id": "audit_costa_20240101_123456",
    "zero_retention": false
  }
}
Interactive Testing Available: Use the API playground below to test endpoints directly with your Costa AI API key.

Authentication

Authorization
string
required
Bearer token with your Costa AI API key. Format: Bearer costa_ent_your_key_here
Content-Type
string
required
Must be application/json
HTTP-Referer
string
Your application URL for usage tracking and analytics
X-Title
string
Human-readable name for your application

Request Body

model
string
required
The Costa AI model to use for completion.Available Models:
  • costa/enterprise-coder-v1 - Optimized for coding tasks
  • costa/secure-claude-3-5-sonnet - Maximum security, advanced reasoning
  • costa/enterprise-gpt-4-turbo - Fast general-purpose model
  • costa/compliance-assistant - Regulatory compliance specialist
messages
array
required
Array of message objects that comprise the conversation.Message Object:
  • role (string): The role of the message author (system, user, or assistant)
  • content (string): The content of the message
max_tokens
integer
default:"1024"
The maximum number of tokens to generate. Range: 1-4096
temperature
number
default:"0.1"
Controls randomness in the response. Range: 0.0-2.0
  • 0.0 = Deterministic
  • 1.0 = Balanced
  • 2.0 = Very creative
security_level
string
default:"standard"
Security level for request processing.Options:
  • standard - Default security measures
  • high - Enhanced security protocols
  • maximum - Highest security, compliance mode
data_residency
string
default:"us-east"
Geographic region for data processing.Available Regions:
  • us-east - US East Coast
  • us-west - US West Coast
  • eu-west - European Union
  • asia-pacific - Asia Pacific
audit_enabled
boolean
default:"true"
Enable comprehensive audit logging for this request.
zero_retention
boolean
default:"false"
Enable zero data retention mode - no data stored after processing.

Interactive Testing

Your API key will only be used for testing and is not stored. Always use a test key for documentation testing.
curl -X POST "https://ai.costa.app/api/v1/chat/completions" \
  -H "Authorization: Bearer costa_ent_your_key_here" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: https://docs.costa.app" \
  -H "X-Title: Costa AI Documentation Test" \
  -d '{
    "model": "costa/enterprise-coder-v1",
    "messages": [
      {
        "role": "user",
        "content": "Write a secure Python function to hash passwords"
      }
    ],
    "max_tokens": 300,
    "temperature": 0.1,
    "security_level": "high"
  }'

Response Format

id
string
Unique identifier for the completion request
object
string
Object type, always chat.completion
created
integer
Unix timestamp when the completion was created
model
string
The Costa AI model used for the completion
choices
array
Array of completion choices
usage
object
Token usage statistics
security
object
Security and compliance information
{
  "id": "chatcmpl-costa-123456789",
  "object": "chat.completion",
  "created": 1704067200,
  "model": "costa/enterprise-coder-v1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here's a secure Python function to hash passwords using bcrypt:\n\n```python\nimport bcrypt\n\ndef hash_password(password: str) -> str:\n    \"\"\"\n    Securely hash a password using bcrypt with salt.\n    \n    Args:\n        password (str): The plain text password to hash\n        \n    Returns:\n        str: The hashed password\n    \"\"\"\n    # Generate salt and hash password\n    salt = bcrypt.gensalt(rounds=12)\n    hashed = bcrypt.hashpw(password.encode('utf-8'), salt)\n    return hashed.decode('utf-8')\n\ndef verify_password(password: str, hashed: str) -> bool:\n    \"\"\"\n    Verify a password against its hash.\n    \n    Args:\n        password (str): Plain text password\n        hashed (str): Hashed password to verify against\n        \n    Returns:\n        bool: True if password matches, False otherwise\n    \"\"\"\n    return bcrypt.checkpw(password.encode('utf-8'), hashed.encode('utf-8'))\n```\n\nThis implementation uses bcrypt with 12 rounds for strong security."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 245,
    "total_tokens": 257,
    "cost_usd": 0.00385
  },
  "security": {
    "level": "high",
    "data_residency": "us-east",
    "audit_id": "audit_costa_20240101_123456",
    "zero_retention": false
  }
}

Error Responses

error
object
Error information when request fails
{
  "error": {
    "message": "Invalid API key provided",
    "type": "authentication_error", 
    "code": "invalid_api_key"
  }
}

Model-Specific Examples

{
  "model": "costa/enterprise-coder-v1",
  "messages": [
    {
      "role": "user",
      "content": "Create a RESTful API endpoint for user authentication with rate limiting"
    }
  ],
  "max_tokens": 500,
  "temperature": 0.1
}

Need Help?

If you encounter issues with the interactive testing or need assistance with integration: