AI API Proxy Development Environment

Complete guide to setting up productive development environments for AI API proxy development. IDE configurations, debugging tools, and best practices.

๐Ÿ’ป

IDE Setup

VS Code, JetBrains

๐Ÿ”ง

Debug Tools

Logging, tracing

๐Ÿงช

Testing

Unit, integration

๐Ÿ“Š

Monitoring

Metrics, dashboards

Essential Development Tools

Core tools every AI API proxy developer needs in their environment:

Runtime Environments

  • Node.js 18+ LTS
  • Python 3.9+
  • Docker Desktop
  • Docker Compose

API Testing

  • Postman or Insomnia
  • curl / httpie
  • HTTPie Desktop
  • Newman (CLI runner)

Code Quality

  • ESLint / Pylint
  • Prettier / Black
  • Git with GitFlow
  • Pre-commit hooks

IDE Configuration

VS Code Setup

Recommended extensions for API development:

Extension Purpose Configuration
REST Client Test APIs directly in editor Enable .http file support
Thunder Client Postman alternative Sync collections
Docker Container management Enable compose support
YAML Configuration editing Schema validation
GitLens Git supercharged Enable blame info
Error Lens Inline error display Show warnings inline

Recommended Settings

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,
  "editor.quickSuggestions": {
    "strings": true
  },
  "yaml.schemas": {
    "https://json.schemastore.org/docker-compose.json": "docker-compose*.yml"
  }
}

Environment Variables Management

Project Structure

project/
โ”œโ”€โ”€ .env.example          # Template file (commit this)
โ”œโ”€โ”€ .env                  # Local secrets (git-ignored)
โ”œโ”€โ”€ .env.test             # Test environment
โ”œโ”€โ”€ .env.production       # Production config
โ””โ”€โ”€ config/
    โ”œโ”€โ”€ development.yaml  # Non-secret config
    โ”œโ”€โ”€ test.yaml
    โ””โ”€โ”€ production.yaml

.env.example Template

# API Provider Keys
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here

# Gateway Configuration
GATEWAY_PORT=8080
ADMIN_PORT=9090
LOG_LEVEL=debug

# Database
DATABASE_URL=postgresql://localhost:5432/gateway_dev
REDIS_URL=redis://localhost:6379

# Security
JWT_SECRET=dev-secret-change-in-production
API_KEY_SALT=dev-salt
Security Best Practice Never commit .env files. Use .env.example as a template and inject secrets via CI/CD or secret management tools.

Testing Framework Setup

Unit Testing (Python)

# requirements-test.txt
pytest>=7.0.0
pytest-cov>=4.0.0
pytest-asyncio>=0.21.0
httpx>=0.24.0

# pytest.ini
[tool:pytest]
testpaths = tests
python_files = test_*.py
asyncio_mode = auto

Integration Testing

import pytest
from httpx import AsyncClient

@pytest.fixture
async def client():
    async with AsyncClient(base_url="http://localhost:8080") as client:
        yield client

async def test_health_endpoint(client):
    response = await client.get("/health/live")
    assert response.status_code == 200
    assert response.json()["status"] == "ok"

async def test_api_completion(client):
    response = await client.post(
        "/v1/completions",
        headers={"Authorization": "Bearer test-key"},
        json={"model": "gpt-3.5", "prompt": "Hello"}
    )
    assert response.status_code == 200

Development Workflow

Daily Development Cycle

  1. Start environment: docker-compose up -d
  2. Run tests: pytest tests/ -v
  3. Make changes: Edit code with live reload enabled
  4. Test manually: Use REST Client or Postman
  5. Check logs: docker-compose logs -f api-gateway
  6. Run linting: eslint . or pylint src/
  7. Commit changes: Git commit with meaningful message
  8. Push to branch: Create PR for code review

Git Branching Strategy

Debugging Tools

Logging Configuration

import logging

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler('logs/gateway.log'),
        logging.StreamHandler()
    ]
)

# Enable HTTP request logging
logging.getLogger("httpx").setLevel(logging.DEBUG)
logging.getLogger("uvicorn").setLevel(logging.DEBUG)

Useful Debug Commands

# View real-time logs
docker-compose logs -f --tail=100 api-gateway

# Check process status
docker-compose top

# Inspect network
docker network ls
docker network inspect project_default

# Debug inside container
docker-compose exec api-gateway sh

# Check resource usage
docker stats

Partner Resources