Package org.machanism.machai.genai.provider
This package is the SDK-facing integration layer. Its providers translate
Machai prompts, instructions, configuration, and reflected tool metadata into
provider-specific requests; submit those requests; execute matching local
tool functions when a model asks for them; append tool results to the
conversation; and record reported token usage. The public provider contract
is ProcessProvider; providers
that generate vectors additionally implement
EmbeddingProvider.
Provider implementations
OpenAIProvideruses the OpenAI Responses API. It supports text prompts, function tools, configured web search and MCP tools, follow-up requests for tool calls, usage accounting, and embeddings. Its client usesOPENAI_API_KEY, the optionalOPENAI_BASE_URL, and the common timeout and output-limit settings described in its class documentation.AnthropicProvideruses the Anthropic Beta Messages API. It keeps user and assistant messages, forwards MCP definitions, supports the supported Anthropic web-search tool versions, invokes local tools, applies cache control to the final local tool, and records input and output usage.CodeMieProvideris a routing adapter. Model names with supported OpenAI-compatible prefixes, including blank model names and embedding prefixes, delegate toOpenAIProvider;claude-*names delegate toAnthropicProvider. It obtains an OAuth 2.0 token using a password grant for an e-mail username or client credentials otherwise, and supports anAUTH_URLtoken-endpoint override.
Shared infrastructure
AbstractAIProvidersupplies common configuration, model and request limits, project-directory context, reflective registration of annotated tools, prompts and resources, safe tool invocation, and MCP and web-search configuration hooks.TypeConverterconverts reflected tool arguments from strings or JSON into Java values and maps supported Java classes to schema type names. It handles scalar values, files, lists, maps, and Jackson JSON nodes.-
is the package-private execution logger. It emits complete serialized payloads at debug level and abbreviated payloads at info level, while recording tool failures with their project context.
invalid reference
ToolLogger
Lifecycle and conversation scope
Initialize a provider with a model and a configured
Configurator, add
prompts and any annotated tool definitions, then call
perform(). A provider may issue additional backend requests while it
resolves model tool calls. Conversation inputs and registered provider state
remain until ProcessProvider.clear()
is called, so an instance represents one conversation and must not be shared
concurrently without external synchronization.
Configurator configurator = configuredCredentials();
ProcessProvider provider = new OpenAIProvider();
provider.init("gpt-4.1", configurator);
provider.prompt("Summarize the project architecture.");
String answer = provider.perform();
provider.clear();
Credentials, endpoint selection, timeouts, search, MCP servers, tool execution, and output limits are backend-specific. Consult the class-level documentation of the concrete provider selected for the accepted keys and delegation behavior. Providers are service adapters rather than a general purpose tool registry; deterministic host-side workflows belong in the separate tools-provider implementation.
- Since:
- 1.2.0
- Author:
- Viktor Tovstyi
-
ClassesClassDescriptionBase implementation of the
ProcessProvidercontract shared by concrete provider integrations.Anthropic-backed implementation of Machai'sProcessProviderabstraction.ProcessProviderimplementation that integrates with EPAM CodeMie.OpenAI-backedProcessProviderimplementation.Utility class for converting between Java types and their string representations, as well as mapping Java types to simplified type names (e.g., "string", "integer", "array").