Experimental API - Context Engine SDK is experimental and subject to breaking changes.
Installation
npm install -g @augmentcode/auggie@latest && npm install @augmentcode/auggie-sdk
Getting Credentials
Sign in to Augment using the CLI:
Your credentials will be stored in ~/.augment/session.json and the SDK will automatically use them.
Alternatively, you can use environment variables:
export AUGMENT_API_TOKEN = "your-api-token"
export AUGMENT_API_URL = "https://your-tenant.api.augmentcode.com"
Finding your tenant URL: After signing in with auggie login, run auggie token print to see your session JSON, including the accessToken and tenantURL. The URL format is https://[your-organization-name].api.augmentcode.com.
Direct Context
Explicitly index files from any source (APIs, databases, memory, disk) with full control over what gets indexed and the ability to save/load state:
import { DirectContext } from '@augmentcode/auggie-sdk' ;
async function main () {
// Authentication is automatic via:
// 1. Options parameters (apiKey, apiUrl passed to create())
// 2. Environment variables (AUGMENT_API_TOKEN, AUGMENT_API_URL)
// 3. ~/.augment/session.json (created by `auggie login`)
const context = await DirectContext . create ();
// Add files to index
const result = await context . addToIndex ([
{ path: 'src/main.ts' , contents: 'export function main() { ... }' },
{ path: 'src/auth.ts' , contents: 'export function authenticate() { ... }' }
]);
console . log ( `Newly uploaded: ${ result . newlyUploaded . length } ` );
console . log ( `Already uploaded: ${ result . alreadyUploaded . length } ` );
// Search - returns formatted string ready for LLM use or display
const results = await context . search ( 'authentication logic' );
console . log ( results );
// Or use searchAndAsk for one-step Q&A
const answer = await context . searchAndAsk (
'How does authentication work?'
);
console . log ( answer );
// Save state to avoid re-indexing
await context . exportToFile ( '/tmp/state.json' );
}
main ();
FileSystem Context
Automatically index and search a local directory - just point to a directory path and start searching, perfect for local development and testing:
import { FileSystemContext } from '@augmentcode/auggie-sdk' ;
async function main () {
const context = await FileSystemContext . create ({
directory: '/path/to/workspace' ,
});
// Search the directory
const results = await context . search ( 'authentication logic' );
console . log ( results );
// Or ask a question
const answer = await context . searchAndAsk (
'How does authentication work?'
);
console . log ( answer );
// Clean up
await context . close ();
}
main ();
Next Steps
Examples See more example applications
API Reference Explore the complete API