When building AI agents, one of the first requirements you might have is to connect your agent to a Large Language Model (LLM). Fortunately, the Agent Stack helps with this by providing built-in OpenAI-compatible LLM inference. The platform’s OpenAI endpoints are model and provider agnostic, serving as a proxy to whatever is configured. For you as an agent builder, the usage is extremely simple because we’ve wrapped the usage into a Service Extension.Documentation Index
Fetch the complete documentation index at: https://ibm-8c0b5b62-gpt-researcher-integration.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
Add LLM service extension to your agent
Import the necessary components and add the LLM service extension to your agent function.
Example of LLM Access
Here’s how to add LLM inference capabilities to your agent:How to request LLM access
Here’s what you need to know to add LLM inference capabilities to your agent: Import the extension: ImportLLMServiceExtensionServer and LLMServiceExtensionSpec from agentstack_sdk.a2a.extensions.
Add the LLM parameter: Add a third parameter to your agent function with the Annotated type hint for LLM access.
Specify your model requirements: Use LLMServiceExtensionSpec.single_demand() to request a single model (multiple models will be supported in the future).
Suggest a preferred model: Pass a tuple of suggested model names to help the platform choose the best available option.
Check if the extension exists: Always verify that the LLM extension is provided before using it, as service extensions are optional.
Access LLM configuration: Use llm.data.llm_fulfillments.get("default") to get the LLM configuration details.
Use with your LLM client: The platform provides api_model, api_key, and api_base that work with OpenAI-compatible clients.
Understanding LLM Configuration
The platform automatically provides you with:api_model: The specific model identifier that was allocated to your requestapi_key: Authentication key for the LLM serviceapi_base: The base URL for the OpenAI-compatible API endpoint
- BeeAI Framework
- LangChain
- LlamaIndex
- OpenAI Python client
- Custom implementations
Model Selection
When you specify a suggested model like"ibm/granite-3-3-8b-instruct", the platform will:
- Check if the requested model is available in your configured environment
- Allocate the best available model that matches your requirements
- Provide you with the exact model identifier and endpoint details