Before you begin
Make sure you have:- an Agumbe Gateway API key
- the Agumbe base URL
- a backend or server-side TypeScript environment
https://api.agumbe.ai/api/v1/llm
Set your API key as an environment variable:
export AGUMBE_API_KEY="your_agumbe_gateway_api_key"
Install the SDK
npm install openai
Even though the package name is openai, you are pointing it at Agumbe AI Gateway, not directly at any one model provider.
Create a client
Send your first chat request
- use a stable alias such as smart-default
- keep the integration server-side
- start simple
- evolve routing and guardrails later through the gateway
Send an embeddings request
Use a specific app policy
If you are using a tenant-scoped API key, you can choose which app’s guardrails apply by sending agumbe_guardrails_app_id.Attach request metadata
Agumbe supports request metadata that makes logs and observability much more useful. You can attach metadata such as:- workspace_id
- xnamespace_id
- source_service
- operation
- external_request_id
Use grounding context
If groundedness checks are part of your app policy, you can send grounding context with the request.Read the response
A successful chat response includes the generated content and token usage.Recommended project structure
A simple server-side structure works well for most teams.src/lib/agumbe.tsservices/summarizer.tsroutes/support.ts\
Example client module:
Error handling
Agumbe returns structured errors. In TypeScript, you should catch errors and handle them deliberately.- invalid credentials
- invalid model selection
- app mismatch
- guardrail policy blocks
- rate limits
- upstream timeout or provider failure
Production recommendations
When integrating from TypeScript, follow these guidelines:- keep the API key in server-side environment variables
- do not expose the key in frontend bundles
- prefer aliases such as smart-default and embed-default
- use app-scoped keys when the workload is fixed
- attach request metadata for important workflows
- send traffic through your backend or service layer
- start with a small number of stable integration patterns
- one backend service
- one app-scoped key
- one chat alias
- one embeddings alias
- one app policy
- request metadata on every important workflow