@ainative/cody-cli 0.7.13 → 0.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: ainative-api-reference
3
+ description: AINative platform API endpoint reference for Cody CLI. Use when (1) Making HTTP calls to api.ainative.studio, (2) Integrating new AINative backend features, (3) Working on auth/login/subscription logic, (4) Debugging API 401/404 errors, (5) Checking which endpoints exist on the gateway. Covers all OAuth, auth, subscription, credits, billing, profile, bootstrap, and LLM endpoints with their auth requirements and response formats.
4
+ ---
5
+
6
+ # AINative API Reference for Cody CLI
7
+
8
+ ## Gateway
9
+
10
+ - **Base URL:** `https://api.ainative.studio`
11
+ - **Client ID:** `ainative-cody-cli-001`
12
+ - **Full docs:** `docs/AINATIVE_API_REFERENCE.md`
13
+
14
+ ## Authentication
15
+
16
+ | Method | Header | Format | Use Case |
17
+ |--------|--------|--------|----------|
18
+ | API Key | `x-api-key` | `sk_...` or platform token | LLM calls, subscription, credits |
19
+ | JWT Bearer | `Authorization: Bearer {jwt}` | JWT from `/api/v1/auth/login` | User profile, settings |
20
+ | OAuth | `Authorization: Bearer {access_token}` | From `/v1/oauth/token` | CLI `/login` flow |
21
+
22
+ **CRITICAL:** `sk-ant-` prefixed keys are Anthropic format and DO NOT work on the AINative gateway. Only `sk_` prefixed keys and platform tokens are valid.
23
+
24
+ ## Subscription & Plan Check
25
+
26
+ **Primary endpoint:** `GET /api/v1/public/subscription`
27
+ - Auth: `x-api-key` or `Authorization: Bearer`
28
+ - Returns: `{success, data: {subscription: {status, plan: {id, name, price, is_active}}}}`
29
+ - Plan IDs: `free`, `starter`, `pro`, `business`, `Enterprise`
30
+ - Active check: `status === "active" && plan.is_active === true`
31
+
32
+ **Credit balance:** `GET /api/v1/credits/balance`
33
+ - Returns: `{total_credits, used_credits, remaining_credits, plan, usage_percentage}`
34
+
35
+ ## User Identity
36
+
37
+ | Endpoint | Method | Auth | Returns |
38
+ |----------|--------|------|---------|
39
+ | `GET /api/v1/auth/me` | GET | Key/JWT | `{id, email, name, email_verified, created_at}` |
40
+ | `GET /api/v1/auth/verify` | GET | Key/JWT | `{authenticated, user_id, email, role, method}` |
41
+ | `POST /api/v1/auth/login` | POST | None | `{access_token, refresh_token, user: {...}}` |
42
+ | `POST /api/v1/auth/refresh` | POST | JWT | `{access_token, token_type, expires_in}` |
43
+
44
+ ## API Key Management
45
+
46
+ | Endpoint | Method | Auth | Returns |
47
+ |----------|--------|------|---------|
48
+ | `GET /api/v1/api-keys/` | GET | Key/JWT | `{total, keys: [{id, name, key_preview, is_active}]}` |
49
+ | `POST /api/v1/api-keys/` | POST | Key/JWT | `{id, name, api_key, key_preview}` (full key shown once) |
50
+ | `PATCH /api/v1/api-keys/{id}/revoke` | PATCH | Key/JWT | `{message, key_id}` |
51
+
52
+ ## Pricing (Public)
53
+
54
+ | Endpoint | Method | Auth | Returns |
55
+ |----------|--------|------|---------|
56
+ | `GET /api/v1/public/pricing/plans` | GET | None | `{success, data: {plans: [{id, name, tier, price, features[]}]}}` |
57
+ | `GET /api/v1/public/subscription/plans` | GET | None | Available plan list |
58
+
59
+ ## CLI Bootstrap
60
+
61
+ | Endpoint | Method | Auth | Returns |
62
+ |----------|--------|------|---------|
63
+ | `GET /api/cody/bootstrap` | GET | x-api-key | `{status, provider, api_base_url, features}` (LEGACY) |
64
+ | `GET /api/v1/cli/bootstrap` | GET | Key/JWT | `{client_data, additional_model_options[], user_plan, user}` (PREFERRED) |
65
+
66
+ **Note:** `/api/cody/bootstrap` is the legacy endpoint currently used by the CLI. `/api/v1/cli/bootstrap` is the newer endpoint with richer data (model catalog with `plan_required` per model, `user_plan`, feature flags, `user` info). Should replace the legacy endpoint.
67
+
68
+ ## Credits & Usage
69
+
70
+ | Endpoint | Method | Auth | Returns |
71
+ |----------|--------|------|---------|
72
+ | `GET /api/v1/public/credits/balance` | GET | Key/JWT | `{total_credits, used_credits, remaining_credits, plan, usage_percentage}` |
73
+ | `GET /api/v1/public/credits/usage/current` | GET | Key/JWT | `{summary: {total_requests, total_credits_used, total_tokens_processed}, daily_usage[]}` |
74
+ | `GET /api/v1/public/subscription/usage` | GET | Key/JWT | `{total_credits_used, total_requests, active_days, monthly_credits_used}` |
75
+ | `GET /api/v1/public/credits/transactions` | GET | Key/JWT | `{transactions[], total_records, total_cost}` |
76
+ | `GET /api/v1/public/credits/packages` | GET | Key/JWT | Available credit packages for purchase |
77
+ | `GET /api/v1/public/credits/auto-refill-settings` | GET | Key/JWT | Auto-refill configuration |
78
+
79
+ ## Endpoints That DO NOT Exist on AINative Gateway
80
+
81
+ These Anthropic/Claude-specific endpoints return 404 and must be skipped:
82
+
83
+ | Endpoint | Status | CLI Must Skip |
84
+ |----------|--------|---------------|
85
+ | `/api/oauth/create_api_key` | 404 | Yes — use `/api/v1/api-keys/` instead |
86
+ | `/api/oauth/roles` | 404 | Yes — use `/api/v1/auth/me` for role |
87
+ | `/api/cody/profile` | 404 | Yes — use `/api/v1/auth/me` for user info |
88
+ | `/api/oauth/profile` | 500 (DB error) | Yes — use `/api/v1/auth/me` for user info |
89
+
90
+ ## LLM Chat Completions
91
+
92
+ | Endpoint | Method | Auth | Purpose |
93
+ |----------|--------|------|---------|
94
+ | `/v1/messages` | POST | x-api-key | Anthropic SDK format, proxied to LLM backend |
95
+
96
+ Gateway translates Anthropic message format to OpenAI chat completions internally.
97
+
98
+ ## Plan Tiers
99
+
100
+ | Plan ID | Name | Price/mo | API Credits | LLM Tokens |
101
+ |---------|------|----------|-------------|------------|
102
+ | `free` | Free | $0 | 1,000 | 10K |
103
+ | `starter` | Starter | $0 | 1,000 | 10K |
104
+ | `pro` | Pro | $49 | 50,000 | 1M |
105
+ | `business` | Business | $149 | 150,000 | 5M |
106
+ | `Enterprise` | Enterprise | $699 | 200,000 | 10M |
107
+
108
+ ## Integration Checklist
109
+
110
+ When adding a new AINative API call to the CLI:
111
+
112
+ 1. **Check this reference first** — the endpoint may not exist on the gateway
113
+ 2. **Use `x-api-key` header** for API key auth (what the Anthropic SDK sends)
114
+ 3. **Use `Authorization: Bearer` header** for JWT/OAuth auth
115
+ 4. **Handle 404 gracefully** — Anthropic-specific endpoints don't exist
116
+ 5. **Handle 500 gracefully** — some OAuth endpoints have DB issues
117
+ 6. **Test against production** before committing: `curl -s https://api.ainative.studio/your/endpoint -H "x-api-key: $AINATIVE_API_TOKEN"`
118
+ 7. **Update this skill** and `docs/AINATIVE_API_REFERENCE.md` when adding new endpoints