Skip to content

GenAI.mil #13

Description

@TingTung93

GenAI has an API now.

Swagger API spec

{"openapi":"3.1.0","info":{"title":"STARK API","description":"Secure Trusted API Resource Kit - API Gateway for managing LLM access across multiple organizations.\n\nSTARK provides:\n- **Authentication**: scoped API keys\n- **Multi-tenant hierarchy**: Organizations → Teams → Users\n- **Rate limiting**: Token and request-based limits\n- **LLM Proxy**: OpenAI and Anthropic-compatible endpoints\n\n## Authentication\n\nEndpoints require authentication via:\n- **API Key**: Scoped API key in format {PREFIX}_{random_64_chars}\n\n## Rate Limiting\n\nLLM proxy endpoints are rate-limited based on:\n- Token usage per time window\n- Requests per minute\n\nRate limit headers are included in responses:\n- X-RateLimit-Limit-Tokens: Token limit\n- X-RateLimit-Remaining-Tokens: Remaining tokens\n- X-RateLimit-Limit-Requests: Request limit\n- X-RateLimit-Remaining-Requests: Remaining requests\n","contact":{"name":"STARK API Support"},"license":{"name":"MIT","url":"https://opensource.org/licenses/MIT"},"version":"0.1.0"},"servers":[{"url":"/","description":"Current server"}],"paths":{"/portal/v1/keys/auth/complete":{"get":{"tags":["Portal"],"summary":"Retrieve a newly created API key using a one-time token.","description":"The token is generated during the PKCE callback and stored in Redis\nwith a 60-second TTL. It can only be consumed once.","operationId":"complete_auth","parameters":[{"name":"token","in":"query","description":"One-time retrieval token from callback redirect","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Created API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreatedResponse"}}}},"404":{"description":"Token not found or expired"}}}},"/v1/chat/completions":{"post":{"tags":["LLM"],"summary":"Create chat completion","description":"Generates a chat completion response for the given messages.\nThis endpoint is OpenAI-compatible and supports streaming.\n\n**Rate Limited**: This endpoint consumes tokens from your quota.","operationId":"proxy_completions","requestBody":{"description":"Chat completion request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}},"required":true},"responses":{"200":{"description":"Chat completion response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}}}},"400":{"description":"Bad request - invalid request body"},"401":{"description":"Unauthorized - missing or invalid authentication"},"403":{"description":"Forbidden - insufficient scope for requested model"},"404":{"description":"Model not found or not enabled"},"429":{"description":"Rate limit exceeded"},"502":{"description":"Bad gateway - upstream LLM error"}}}},"/v1/models":{"get":{"tags":["LLM"],"summary":"List available LLM models","description":"Returns a list of all active LLM models available through the proxy.\nThis endpoint is OpenAI-compatible.","operationId":"list_models","responses":{"200":{"description":"List of available models","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelsListResponse"}}}},"401":{"description":"Unauthorized - missing or invalid authentication"},"500":{"description":"Internal server error"}}}}},"components":{"schemas":{"ApiKeyCreatedResponse":{"type":"object","description":"API key creation response (includes the secret key)","required":["id","key","name","scopes","status"],"properties":{"expires_at":{"type":["string","null"],"format":"date-time","description":"When the key expires (if set)"},"id":{"type":"string","format":"uuid","description":"API key ID"},"key":{"type":"string","description":"The full API key - ONLY SHOWN ONCE","example":"STARK_a1b2c3d4e5f6..."},"name":{"type":"string","description":"Human-readable name for the key","example":"My API Key"},"scopes":{"type":"array","items":{"type":"string"},"description":"Scopes granted to this key"},"status":{"type":"string","description":"Key status","example":"active"}}},"ChatChoice":{"type":"object","description":"Chat completion choice","required":["index","message"],"properties":{"finish_reason":{"type":["string","null"],"description":"Reason for finishing","example":"stop"},"index":{"type":"integer","format":"int32","description":"Index of this choice","example":0},"message":{"$ref":"#/components/schemas/ChatMessage","description":"The generated message"}}},"ChatCompletionRequest":{"type":"object","description":"Chat completion request (OpenAI-compatible)","required":["model","messages"],"properties":{"max_tokens":{"type":["integer","null"],"format":"int32","description":"Maximum tokens to generate","example":1000},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"},"description":"Messages in the conversation"},"model":{"type":"string","description":"Model to use for completion","example":"gpt-4"},"stream":{"type":["boolean","null"],"description":"Whether to stream the response","example":false},"temperature":{"type":["number","null"],"format":"float","description":"Sampling temperature (0-2)","example":0.7}}},"ChatCompletionResponse":{"type":"object","description":"Chat completion response (OpenAI-compatible)","required":["id","object","created","model","choices"],"properties":{"choices":{"type":"array","items":{"$ref":"#/components/schemas/ChatChoice"},"description":"Completion choices"},"created":{"type":"integer","format":"int64","description":"Unix timestamp of creation","example":1686935002},"id":{"type":"string","description":"Unique identifier for the completion","example":"chatcmpl-abc123"},"model":{"type":"string","description":"Model used","example":"gpt-4"},"object":{"type":"string","description":"Object type","example":"chat.completion"},"usage":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/Usage","description":"Token usage statistics"}]}}},"ChatMessage":{"type":"object","description":"Chat message","required":["role","content"],"properties":{"content":{"type":"string","description":"Content of the message","example":"Hello, how are you?"},"role":{"type":"string","description":"Role of the message sender","example":"user"}}},"ModelObject":{"type":"object","description":"Model object in the models list","required":["id","object","created","owned_by"],"properties":{"created":{"type":"integer","format":"int64","description":"Unix timestamp of model creation","example":1686935002},"id":{"type":"string","description":"Model identifier","example":"gpt-4"},"object":{"type":"string","description":"Object type (always \"model\")","example":"model"},"owned_by":{"type":"string","description":"Owner of the model","example":"stark-proxy"}}},"ModelsListResponse":{"type":"object","description":"OpenAI-compatible models list response","required":["object","data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ModelObject"},"description":"List of available models"},"object":{"type":"string","description":"Object type (always \"list\")","example":"list"}}},"Usage":{"type":"object","description":"Token usage statistics","required":["prompt_tokens","completion_tokens","total_tokens"],"properties":{"completion_tokens":{"type":"integer","format":"int32","description":"Tokens used in the completion","example":50},"prompt_tokens":{"type":"integer","format":"int32","description":"Tokens used in the prompt","example":10},"total_tokens":{"type":"integer","format":"int32","description":"Total tokens used","example":60}}}}},"tags":[{"name":"LLM","description":"LLM proxy endpoints - OpenAI and Anthropic compatible"},{"name":"Portal","description":"User self-service portal for managing API keys and viewing usage"}]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions