> ## Documentation Index
> Fetch the complete documentation index at: https://docs.augmentcode.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with the Augment Context Engine SDK in minutes

<Warning>
  **Experimental API** - Context Engine SDK is experimental and subject to breaking changes.
</Warning>

## Installation

<CodeGroup>
  ```bash TypeScript theme={null}
  npm install -g @augmentcode/auggie@latest && npm install @augmentcode/auggie-sdk
  ```

  ```bash Python theme={null}
  npm install -g @augmentcode/auggie@latest
  pip install auggie-sdk
  ```
</CodeGroup>

## Getting Credentials

Sign in to Augment using the CLI:

```bash theme={null}
auggie login
```

Your credentials will be stored in `~/.augment/session.json` and the SDK will automatically use them.

Alternatively, for automation or non-interactive environments, set the `AUGMENT_SESSION_AUTH` environment variable to the session JSON:

```bash theme={null}
auggie token print  # Get your session JSON
export AUGMENT_SESSION_AUTH='<session-json>'
```

<Note>
  The session JSON includes both your access token and tenant URL, so no separate URL variable is needed. Run `auggie token print` after logging in to get the full session JSON.
</Note>

## 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:

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { DirectContext } from '@augmentcode/auggie-sdk';

  async function main() {
    // Authentication is automatic via:
    // 1. Options parameters (apiKey, apiUrl passed to create())
    // 2. AUGMENT_SESSION_AUTH environment variable (session JSON from `auggie token print`)
    // 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();
  ```

  ```python Python theme={null}
  from auggie_sdk.context import DirectContext, File

  def main():
      # Authentication is automatic via:
      # 1. Options parameters (api_key, api_url passed to create())
      # 2. AUGMENT_SESSION_AUTH environment variable (session JSON from `auggie token print`)
      # 3. ~/.augment/session.json (created by `auggie login`)
      context = DirectContext.create()

      # Add files to index
      result = context.add_to_index([
          File(path='src/main.py', contents='def main(): ...'),
          File(path='src/auth.py', contents='def authenticate(): ...')
      ])

      print(f"Newly uploaded: {len(result.newly_uploaded)}")
      print(f"Already uploaded: {len(result.already_uploaded)}")

      # Search - returns formatted string ready for LLM use or display
      results = context.search('authentication logic')
      print(results)

      # Or use search_and_ask for one-step Q&A
      answer = context.search_and_ask(
          'How does authentication work?'
      )
      print(answer)

      # Save state to avoid re-indexing
      context.export_to_file('/tmp/state.json')

  if __name__ == '__main__':
      main()
  ```
</CodeGroup>

## FileSystem Context

Automatically index and search a local directory - just point to a directory path and start searching, perfect for local development and testing:

<CodeGroup>
  ```typescript TypeScript theme={null}
  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();
  ```

  ```python Python theme={null}
  from auggie_sdk.context import FileSystemContext

  def main():
      # Use context manager for automatic cleanup
      with FileSystemContext.create('/path/to/workspace') as context:
          # Search the directory
          results = context.search('authentication logic')
          print(results)

          # Or ask a question
          answer = context.search_and_ask(
              'How does authentication work?'
          )
          print(answer)

  if __name__ == '__main__':
      main()
  ```
</CodeGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Examples" icon="lightbulb" href="/context-services/sdk/examples">
    See more example applications
  </Card>

  <Card title="API Reference" icon="code" href="/context-services/sdk/api-reference">
    Explore the complete API
  </Card>
</CardGroup>
