@genkit-ai/compat-oai
Version:
Genkit AI framework plugin for OpenAI APIs.
75 lines (71 loc) • 2.86 kB
TypeScript
import { z, ModelReference } from 'genkit';
import { GenkitPlugin } from 'genkit/plugin';
import { ImageGenerationCommonConfigSchema } from '../image.js';
import { PluginOptions } from '../index.js';
import { SUPPORTED_IMAGE_MODELS } from './grok-image.js';
import { SUPPORTED_LANGUAGE_MODELS, XaiChatCompletionConfigSchema } from './grok.js';
import 'genkit/model';
import 'openai';
import 'openai/resources/images.mjs';
import 'genkit/registry';
import '../audio.js';
import 'openai/resources/audio/index.mjs';
import '../embedder.js';
import '../model.js';
import 'openai/resources/index.mjs';
import 'zod';
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
type XAIPluginOptions = Omit<PluginOptions, 'name' | 'baseURL'>;
declare function xAIPlugin(options?: XAIPluginOptions): GenkitPlugin;
type XAIPlugin = {
(params?: XAIPluginOptions): GenkitPlugin;
model(name: keyof typeof SUPPORTED_LANGUAGE_MODELS, config?: z.infer<typeof XaiChatCompletionConfigSchema>): ModelReference<typeof XaiChatCompletionConfigSchema>;
model(name: keyof typeof SUPPORTED_IMAGE_MODELS, config?: z.infer<typeof ImageGenerationCommonConfigSchema>): ModelReference<typeof ImageGenerationCommonConfigSchema>;
model(name: string, config?: any): ModelReference<z.ZodTypeAny>;
};
/**
* This module provides an interface to the XAI models through the Genkit
* plugin system. It allows users to interact with various models by providing
* an API key and optional configuration.
*
* The main export is the `xai` plugin, which can be configured with an API
* key either directly or through environment variables. It initializes the
* OpenAI client and makes available the models for use.
*
* Exports:
* - xAI: The main plugin function to interact with XAI, via OpenAI
* compatible API.
*
* Usage: To use the models, initialize the xAI plugin inside
* `configureGenkit` and pass the configuration options. If no API key is
* provided in the options, the environment variable `OPENAI_API_KEY` must be
* set.
*
* Example:
* ```
* import { xAI } from '@genkit-ai/compat-oai/xai';
*
* export default configureGenkit({
* plugins: [
* xAI()
* ... // other plugins
* ]
* });
* ```
*/
declare const xAI: XAIPlugin;
export { type XAIPlugin, type XAIPluginOptions, xAI as default, xAI, xAIPlugin };