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.

PropertyTypeDescription
apistringCurrent API endpoint
provider"google" | "anthropic" | "openai" | undefinedCurrent provider
modelstring | undefinedCurrent model identifier
headersRecord<string, string> | undefinedCurrent 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.