Skip to content

Add metadata field to all OpenAI API request structs #866

Open
@youssefsiam38

Description

@youssefsiam38

Is your feature request related to a problem? Please describe.

As LLM use grows, so does the need for tracing, debugging, and testing. The feature request is to attach custom metadata to API requests for logging, tracing, or tool integration. The current go-openai library lacks a standardized way to include this metadata in request structs.

Describe the solution you'd like

Add a Metadata field of type map[string]interface{} to all structs representing request bodies for OpenAI APIs. For example:

ChatCompletionRequest struct {
    // ... existing fields ...
    Metadata map[string]interface{} `json:"metadata,omitempty"`
}

Apply this change consistently across all relevant request structs.

Additional context

This feature would align go-openai with other OpenAI libraries and tools that support metadata, such as LiteLLM proxy, enabling easier integration with logging and tracing systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions