export { AIGatewayService, AIGatewayChatCompletionParamsSchema, AIGatewayChatCompletionSchema, AIGatewayChatMessageSchema, AIGatewayModelProviderSchema, AIGatewayModelSchema, AIGatewayModelsResponseSchema, AIGatewayModelsSchema, AIGatewayPricingSchema, } from '@agentuity/core/aigateway';
import { AIGatewayService, } from '@agentuity/core/aigateway';
import { createMinimalLogger, getEnv } from '@agentuity/core';
import { getServiceUrls } from '@agentuity/core/config';
import { buildClientHeaders, createServerFetchAdapter } from '@agentuity/server';
import { z } from 'zod';
const isLogger = (val) => typeof val === 'object' &&
    val !== null &&
    ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
export const AIGatewayClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the AI Gateway API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class AIGatewayClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = AIGatewayClientOptionsSchema.parse(options);
        const apiKey = validatedOptions.apiKey ||
            getEnv('AGENTUITY_AIGATEWAY_KEY') ||
            getEnv('AGENTUITY_SDK_KEY') ||
            getEnv('AGENTUITY_CLI_KEY');
        const region = getEnv('AGENTUITY_REGION') ?? 'usc';
        const serviceUrls = getServiceUrls(region);
        const url = validatedOptions.url || getEnv('AGENTUITY_AIGATEWAY_URL') || serviceUrls.aigateway;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, logger);
        this.#service = new AIGatewayService(url, adapter);
    }
    async listModels() {
        return this.#service.listModels();
    }
    async complete(params) {
        return this.#service.complete(params);
    }
}
//# sourceMappingURL=index.js.map