@anuma/portal
v1.0.0
Published
Anuma Portal is a prepaid escrow-based API gateway for wallet-authenticated LLM usage. It provides an OpenAI-compatible API with on-chain settlement for AI inference costs.
Readme
AI Portal
AI Portal is a prepaid escrow-based API gateway for wallet-authenticated LLM usage. It provides an OpenAI-compatible API with on-chain settlement for AI inference costs.
server: Handles API requests, user authentication, billing, and manages communication with LLM providers.worker: Processes AI inference settlements.
Getting Started
Prerequisites
- Go 1.23+
- PostgreSQL 15+
- ZetaChain RPC endpoint
- golangci-lint v2 (for development)
go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
Accessing the Private Escrow Contract Repository
The escrow contract sources live in the private github.com/zeta-chain/escrow-contract repository. Configure Go and Git to always use SSH when cloning from github.com/zeta-chain/* to avoid authentication errors:
- Set
GOPRIVATE(note that you can add this to your shell profile):export GOPRIVATE=github.com/zeta-chain/* - Update your
~/.gitconfigto prefer the SSH remote for GitHub:[url "[email protected]:"] insteadOf = https://github.com/
Installation
make installInstall only server
make install-serverInstall only worker
make install-workerConfiguration
See .env.example for available configuration options. Create .env with based on this file.
Running Tests
make testGenerate API specification and client
make generateThis command regenerates both the Swagger specification in docs and the
TypeScript client in typescript.
Run E2E Test
The e2e tests use two configuration files:
.env.test(committed): All public test configuration values.env.test.local(gitignored): Secrets likeGITHUB_PATand optional Privy credentials
Setup:
- The
.env.testfile is already in the repository with all public test values - Create a
.env.test.localfile (gitignored) with your secrets:# Required for Docker builds (private repos) GITHUB_PAT=your_github_pat_here
Authentication coverage:
| E2E test | Authentication |
| --- | --- |
| chat_completion | Privy JWT (Bearer token) |
| chat_completion_stream | Privy JWT (Bearer token) |
| embeddings | Privy JWT (Bearer token) |
| response_api_chat | Privy JWT (Bearer token) |
| response_api_image_gen | Privy JWT (Bearer token) |
| chat_completions_image | Privy JWT (Bearer token) |
| chat_completion_api_key | API key (X-API-Key) |
| chat_completion_stream_api_key | API key (X-API-Key) |
Run E2E tests:
Single command to start everything and run E2E tests:
make test-e2eThis will:
- Start all Docker services (Anvil, Postgres, Server, Worker)
- Deploy contracts to Anvil
- Submit api requests
- Worker detects contracts and starts processing
- Verify entries in Postgres DB are created
Running with Frontend
To run the local development environment with the frontend UI:
make localnet-frontendNote: The frontend image (ai-memoryless-client) must be built first from the ai-memoryless-client repository:
docker build -f apps/web/Dockerfile -t ai-memoryless-client \
--build-arg NEXT_PUBLIC_API_URL=http://localhost:8080 \
--build-arg NEXT_PUBLIC_PRIVY_APP_ID=<privy-app-id> \
.The frontend will be available at http://localhost:8787.
Deployment
AI Portal is deployed to two environments:
| Environment | URL | Deployment |
|-------------|-----|------------|
| Dev | https://portal.anuma-dev.ai | Automatic on push to main |
| Prod | https://portal.anuma.ai | Manual with version tags |
See INFRASTRUCTURE.md for detailed deployment instructions and CI/CD documentation.
