From d6a9ed379285907a3672dda40955d9d4ba947900 Mon Sep 17 00:00:00 2001 From: Botir Khaltaev Date: Tue, 15 Jul 2025 15:50:07 +0100 Subject: [PATCH 1/2] docs(providers): add Adaptive Provider documentation This commit introduces comprehensive documentation for the Adaptive Provider. It covers installation, provider instance configuration, and language model usage with automatic model selection and cost bias options. The documentation explains how to set up the provider and leverage its intelligent routing capabilities for optimal performance and cost efficiency. --- .../03-community-providers/100-adaptive.mdx | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 content/providers/03-community-providers/100-adaptive.mdx diff --git a/content/providers/03-community-providers/100-adaptive.mdx b/content/providers/03-community-providers/100-adaptive.mdx new file mode 100644 index 000000000000..51cd9ea44e28 --- /dev/null +++ b/content/providers/03-community-providers/100-adaptive.mdx @@ -0,0 +1,127 @@ +# Adaptive Provider + +The [Adaptive provider](https://ai-sdk.dev/providers/ai-sdk-providers/adaptive) provides intelligent model selection and routing across multiple AI services for optimal performance and cost efficiency. + +## Setup + +The Adaptive provider is available in the `@adaptive-llm/adaptive` module. You can install it with + +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ + +## Provider Instance + +You can import the default provider instance `adaptive` from `@adaptive-llm/adaptive`: + +```ts +import { adaptive } from '@adaptive-llm/adaptive'; +``` + +If you need a customized setup, you can import `createAdaptive` from `@adaptive-llm/adaptive` +and create a provider instance with your settings: + +```ts +import { createAdaptive } from '@adaptive-llm/adaptive'; + +const adaptive = createAdaptive({ + // custom settings +}); +``` + +You can use the following optional settings to customize the Adaptive provider instance: + +- **baseURL** *string* + + Use a different URL prefix for API calls, e.g. to use proxy servers. + The default prefix is `http://localhost:8080/v1`. + +- **apiKey** *string* + + API key that is being sent using the `Authorization` header. + It defaults to the `ADAPTIVE_API_KEY` environment variable. + +- **headers** *Record\* + + Custom headers to include in the requests. + +- **fetch** *(input: RequestInfo, init?: RequestInit) =\> Promise\* + + Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. + Defaults to the global `fetch` function. + You can use it as a middleware to intercept requests, + or to provide a custom fetch implementation for e.g. testing. + +- **defaultProvider** *string* + + Default provider to use for comparisons and fallbacks. + +## Language Models + +You can create models that call the Adaptive API using a provider instance. The Adaptive provider automatically selects the best available underlying model based on your prompt and configured settings for optimal performance and cost efficiency. + +```ts +const model = adaptive(); // Adaptive provider automatically selects the model +``` + +The Adaptive provider supports additional provider options: + +```ts +const model = adaptive(); // Adaptive provider automatically selects the model + +await generateText({ + model, + providerOptions: { + costBias: 0.8, + }, +}); +``` + +The following optional provider options are available for Adaptive models: + +- **costBias** *number* + + Bias towards cost-optimized selections (0-1, where 1 prioritizes cost). + +### Example + +You can use Adaptive language models to generate text with the `generateText` function: + +```ts +import { adaptive } from '@adaptive-llm/adaptive'; +import { generateText } from 'ai'; + +const { text } = await generateText({ + model: adaptive(), // Adaptive provider automatically selects the model + prompt: 'Write a vegetarian lasagna recipe for 4 people.', +}); +``` + +Adaptive language models can also be used in the `streamText`, `generateObject`, and `streamObject` functions +(see [AI SDK Core](https://www.google.com/search?q=/docs/ai-sdk-core)). + +### Model Capabilities + +The Adaptive provider automatically selects from available underlying providers and models, supporting: + +- **Image Input**: Depends on selected underlying model +- **Object Generation**: Supported across most underlying models +- **Tool Usage**: Supported across most underlying models +- **Tool Streaming**: Supported across most underlying models + +The specific capabilities depend on which underlying model is selected by the Adaptive routing system. + +## Text Embedding Models + +Text embedding is not currently supported by the Adaptive provider. From a02d8f1256de0191a78911b608db057e14829dfa Mon Sep 17 00:00:00 2001 From: Botir Khaltaev Date: Tue, 15 Jul 2025 15:53:15 +0100 Subject: [PATCH 2/2] refactor(docs): update Adaptive provider option types to use underscores for consistency style(docs): reformat Adaptive provider option descriptions for improved readability --- .../03-community-providers/100-adaptive.mdx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/content/providers/03-community-providers/100-adaptive.mdx b/content/providers/03-community-providers/100-adaptive.mdx index 51cd9ea44e28..6892b66eca92 100644 --- a/content/providers/03-community-providers/100-adaptive.mdx +++ b/content/providers/03-community-providers/100-adaptive.mdx @@ -42,30 +42,30 @@ const adaptive = createAdaptive({ You can use the following optional settings to customize the Adaptive provider instance: -- **baseURL** *string* +- **baseURL** _string_ - Use a different URL prefix for API calls, e.g. to use proxy servers. - The default prefix is `http://localhost:8080/v1`. + Use a different URL prefix for API calls, e.g. to use proxy servers. + The default prefix is `http://localhost:8080/v1`. -- **apiKey** *string* +- **apiKey** _string_ - API key that is being sent using the `Authorization` header. - It defaults to the `ADAPTIVE_API_KEY` environment variable. + API key that is being sent using the `Authorization` header. + It defaults to the `ADAPTIVE_API_KEY` environment variable. -- **headers** *Record\* +- **headers** _Record\_ - Custom headers to include in the requests. + Custom headers to include in the requests. -- **fetch** *(input: RequestInfo, init?: RequestInit) =\> Promise\* +- **fetch** _(input: RequestInfo, init?: RequestInit) =\> Promise\_ - Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. - Defaults to the global `fetch` function. - You can use it as a middleware to intercept requests, - or to provide a custom fetch implementation for e.g. testing. + Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. + Defaults to the global `fetch` function. + You can use it as a middleware to intercept requests, + or to provide a custom fetch implementation for e.g. testing. -- **defaultProvider** *string* +- **defaultProvider** _string_ - Default provider to use for comparisons and fallbacks. + Default provider to use for comparisons and fallbacks. ## Language Models @@ -90,9 +90,9 @@ await generateText({ The following optional provider options are available for Adaptive models: -- **costBias** *number* +- **costBias** _number_ - Bias towards cost-optimized selections (0-1, where 1 prioritizes cost). + Bias towards cost-optimized selections (0-1, where 1 prioritizes cost). ### Example