DocsAgentAPI ReferenceprovideAgent()

provideAgent()

provideAgent() registers global defaults for every agent() call in an Angular application. Call it once in bootstrapApplication or an ApplicationConfig when multiple agents share the same LangGraph API URL, transport, or license token.

Per-call options still win over provider defaults, so you can configure the common case globally and override individual agents when needed.

import { bootstrapApplication } from '@angular/platform-browser';
import {
  provideAgent,
  MockAgentTransport,
} from '@ngaf/langgraph';
import { AppComponent } from './app/app.component';
 
bootstrapApplication(AppComponent, {
  providers: [
    provideAgent({
      apiUrl: 'http://localhost:2024',
      license: environment.ngafLicense,
      transport: environment.testMode
        ? new MockAgentTransport()
        : undefined,
    }),
  ],
});

Global configuration

OptionTypeDescription
apiUrlstringDefault LangGraph Platform API base URL. Individual agent() calls may override it.
transportAgentTransportOptional transport instance. Defaults to FetchStreamTransport when omitted.
licensestringOptional signed license token. Development and noncommercial use can omit it.

Defaults and overrides

Provider defaults are merged with call-site options. The call site takes precedence.

provideAgent({ apiUrl: 'https://api.example.com' });
 
const productionAgent = agent({
  assistantId: 'support-agent',
});
 
const localAgent = agent({
  apiUrl: 'http://localhost:2024',
  assistantId: 'dev-agent',
});

Test transports

transport is an object that implements AgentTransport, not an Angular class token. Create an instance before passing it to provideAgent() or to an individual agent() call.

const transport = new MockAgentTransport();
 
TestBed.configureTestingModule({
  providers: [
    provideAgent({
      apiUrl: '',
      transport,
    }),
  ],
});
Per-call override

You do not need provideAgent() for one-off tests. Passing transport: new MockAgentTransport() directly to agent() is often simpler and keeps the test fixture explicit.

What's Next

provideAgentfunction

Angular provider factory that registers global defaults for all agent instances in the application.

provideAgent(config: AgentConfig): Provider

Parameters

ParameterTypeDescription
configAgentConfig

Returns

Provider