useAllemAIConfig
Hook to access the current AllemAIProvider context values. Useful when you need to read the configured api, provider, model, or headers outside of the chat/completion hooks.
import { useAllemAIConfig } from "@allem-sdk/ai";Returns
AllemAIConfig — The current provider context values.
| Property | Type | Description |
|---|---|---|
| api | string | Current API endpoint |
| provider | "google" | "anthropic" | "openai" | undefined | Current provider |
| model | string | undefined | Current model identifier |
| headers | Record<string, string> | undefined | Current headers |
Usage
const config = useAllemAIConfig();
// Use the configured API endpoint for custom requests
const res = await fetch(config.api, {
method: "POST",
headers: { ...config.headers, "Content-Type": "application/json" },
body: JSON.stringify({ prompt: "Hello" }),
});
// Conditionally render based on provider
if (config.provider === "anthropic") {
return <AnthropicBadge />;
}Tip
useAllemChat and useAllemCompletion already read from the provider context automatically. Use useAllemAIConfig only when you need direct access to the config values.