OpenAI-compatible API for private, TEE-verifiable AI inference, powering cloud.near.ai
翻譯準備中
取自儲存庫 README
正在載入完整 README。
檢視完整 README ↗A Rust-based cloud API for AI model inference, conversation management, and organization administration. Part of the NEAR AI platform alongside the Chat API.
Clone the repository:
git clone <repository-url>
cd cloud-api
Start services with Docker Compose:
docker-compose up -d
This starts:
Run without Docker:
make dev
This automatically:
schema service (needs Docker and the pinned image)For an end-to-end walkthrough — mock auth, creating an org/workspace/API key,
and exercising chat completions with curl — see
docs/local-development.md.
The schema is owned by nearai/cloud-platform.
cloud-api has no migrations and never migrates at startup. A schema change lands in
cloud-platform first; this repo then bumps the image pin in
scripts/cloud-platform-schema.env. scripts/apply-schema.sh applies the pinned schema to a
local or test database; make dev applies it through the compose schema service. Deploys run
cloud-platform migrate before cloud-api starts.
cargo-nextest 0.9.98 or newer (cargo install cargo-nextest --locked)# Run unit tests only
make test-unit
# Run integration/e2e tests only (requires database)
make test-integration
# Run both unit and integration tests
make test
Tests use the same environment variables as the main application (from env.example).
If environment variables are not set, tests use sensible defaults for local testing.
The nextest setup script creates TEST_DATABASE_NAME and applies the schema once before the
E2E processes start.
# Start test database
docker run --name test-postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=platform_api \
-p 5432:5432 \
-d postgres:latest
# Run tests with default values (or override with env vars)
make test-integration
# Or with custom database settings
DATABASE_HOST=localhost \
DATABASE_PORT=5432 \
DATABASE_NAME=platform_api \
TEST_DATABASE_NAME=platform_api_e2e \
DATABASE_USERNAME=postgres \
DATABASE_PASSWORD=postgres \
make test-integration
Set these environment variables before running tests:
export DATABASE_HOST=localhost
export DATABASE_PORT=5432
export DATABASE_NAME=platform_api # Database-crate integration tests
export TEST_DATABASE_NAME=platform_api_e2e # Use a dedicated test database
export DATABASE_USERNAME=your_username
export DATABASE_PASSWORD=your_password
export DATABASE_TLS_ENABLED=false
make test-integration maps these connection values to the PG* variables
used by database-crate integration tests. Explicit PGHOST, PGPORT,
PGDATABASE, PGUSER, and PGPASSWORD values take precedence.
Copy env.example to .env and configure your test database:
cp env.example .env
# Edit .env with your database credentials
make test-integration
The E2E helpers load .env; for non-default database-crate credentials, also
export the variables shown in Option 2 before running the Make target.
The vLLM integration tests require a running vLLM instance. Configure using environment variables:
# Configure vLLM endpoint
export VLLM_BASE_URL=http://localhost:8002
export VLLM_API_KEY=your_vllm_api_key_here # Optional
export VLLM_TEST_TIMEOUT_SECS=30 # Optional
# Run vLLM integration tests
cargo nextest run --test integration_tests
If not set, tests will use default values but may fail if vLLM is not running at the default URL.
The application uses YAML configuration files located in the config/ directory.
This project uses cargo-audit to check for security vulnerabilities in dependencies. The audit runs automatically:
Cargo.toml or Cargo.lockFailed audits will block PRs. To run locally:
cargo install cargo-audit
cargo audit
Known advisories without available fixes are documented and ignored in .cargo/audit.toml.
Dependabot is enabled to automatically create PRs for:
Before committing code:
Run all checks with a single command:
make preflight
This runs:
-D warnings)Once all checks pass, you're ready to commit!
For Jev and self-hosted decision models, see System One integration.
Interactive API documentation is available when running the server:
http://localhost:3000/docs - Modern, beautiful API documentation with interactive playgroundhttp://localhost:3000/api-docs/openapi.json - Machine-readable OpenAPI specificationThe documentation is generated from Rust code using utoipa and served via Scalar for an enhanced developer experience.
Licensed under the PolyForm Strict License 1.0.0.