Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Passing Arbitrary Extra Metadata in API Requests #1881

Open
HaruHunab1320 opened this issue Jun 7, 2024 · 0 comments
Open

Support for Passing Arbitrary Extra Metadata in API Requests #1881

HaruHunab1320 opened this issue Jun 7, 2024 · 0 comments
Labels
ai/provider enhancement New feature or request

Comments

@HaruHunab1320
Copy link

Feature Description

Issue: Lack of Support for Passing Arbitrary Extra Metadata in API Requests

Description:
The current Vercel AI SDK does not support passing arbitrary extra metadata into the body of the API request neither in and of the providers or the streamText, and generateText methods. This is problematic when integrating with proxies requiring specific settings.

Workaround:
I created a custom provider, openai-provider-metadata-extension-vercel-ai-sdk, to address this limitation. It allows arbitrary metadata to be included in API requests, providing greater flexibility and customization.

Example:

const openai = createOpenAI({
  baseURL: 'https://api.openai.com/v1',
  apiKey: 'YOUR_API_KEY',
  extraMetadata: {
    customField1: 'value1',
    customField2: 'value2',
    // Include any additional metadata fields as needed
  },
});

By leveraging this custom OpenAI provider, developers can easily extend the capabilities of the Vercel AI SDK and include arbitrary metadata in their API requests. This opens up new possibilities for customization, tracking, analytics, and more, empowering developers to build more advanced and tailored applications with the Vercel AI SDK.

Proposed Solution:
Add support for extra metadata fields in the streamText and generateText methods. Additionally, I could contribute the modified providers along with these improvements to ensure seamless metadata handling.

Contribution Offer:
I have implemented these modifications for my use case and am willing to submit a pull request with the necessary changes. If the absence of this feature was intentional, please let me know.

Impact:
Enhancing the SDK with this feature will increase its flexibility and adaptability, benefiting various integration scenarios and use cases.

I look forward to your feedback and am ready to collaborate on this improvement.

Use Case

Proxy Integration: Enable developers to include proxy-specific settings directly in API requests.
Custom Analytics: Allow for the inclusion of analytics metadata for tracking request performance.
Feature Flags: Pass feature flags or experimental settings to the API without altering the core request structure.
User Context: Include user-specific metadata for personalized responses from the API.
Extended Logging: Add additional logging information to requests for better debugging and monitoring.

Additional context

No response

@lgrammel lgrammel added enhancement New feature or request ai/provider labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants