Adding Metadata

Adding Metadata

You can add metadata to each request by adding the x-props-metadata header to your request. This header should be an stringified JSON object with any key-value pairs you want to include. This metadata will be included in the logs and can be used for debugging and tracking purposes.

from openai import OpenAI;
import json
 
client = OpenAI(
    baseUrl = "https://proxy.getprops.ai/"
    defaultHeaders = {
        "x-api-key": "<PROPS_API_KEY>",
        # ADD THIS HEADER
        "x-props-metadata": json.dumps({
            "user": "default-user",
			"custom_metadata_1": 100,
			"custom_metadata_2:" "custom-default-value",
        })
    }
)
 
chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-4-turbo",
    user="specific-user", # takes priority over user in x-props-metadata
    # OPTIONAL - here you can overwrite x-props-metadata
    extra_headers={
        "x-props-metadata": {
            "user": "specific-user"
            "custom_metadata_1": 1000,
			"custom_metadata_2:" "custom-specific-value",            
        }
    
    }
)