opencost / opencost-plugins

Plugins for extending OpenCost with new Custom Cost Sources
Apache License 2.0
19 stars 9 forks source link

OpenCost Plugin for OpenAI usage data #22

Closed lmello closed 1 month ago

lmello commented 4 months ago

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

Describe the solution you'd like Integrate the openai usage data and costs with opencost.

Describe alternatives you've considered NA

Additional context

dwbrown2 commented 3 months ago

Thanks for creating this FR, I've talked with 2-3 teams that have requested this recently. Any interest in working on this? Last I heard OpenAI has billing usage APIs but they are undocumented.

cc @kwombach12 who I believe is also interested in this!

kwombach12 commented 3 months ago

We would love to collaborate with you on this @lmello! If you're interested, here is a blog post on how to get started.

PS: We are offering $1,000 for accepted plug-in contributions as we start to build out our library!

lmello commented 3 months ago

I am working to build an OpenAI usage dashboard in zendesk to track our usage, currently their usage api is undocumented and broken (v1/usage). I talked with the TAM assigned to us and they plan to fix it and release a working api but I didn’t got any dates yet.

The work around I did was using the export api from the usage dashboard , but those api’s only work with a session credential instead of an api key.

I don’t know if we would want to build this integration using a session credential provided this would require us to update the credential every two weeks.

lmello commented 3 months ago

The current usage api returns the usage models, metrics for the model and this can be used to calculate the cost, but it does not return the api key or user id which are essential to display usage and cost per user.

We might be able to use it to display cost and usage per model until they fix the v1/usage api.

kwombach12 commented 3 months ago

@lmello interesting! I think it would be worth looking at the cost/usage per model until they fix that API. Is that something you'd be interested in working on with us?

lmello commented 2 months ago

@kwombach12 discussed it with @ameijer and we will have a meeting next week to start this work. I already shared some details about the api with him in slack.

kwombach12 commented 2 months ago

@lmello That's awesome! Please let me know if I can be of any help testing, identifying scope, or providing feedback. Super excited to work with you on this!

lmello commented 2 months ago

@kwombach12 I am working on it with @ameijer .

ameijer commented 1 month ago

basic implementation undergoing review here: https://github.com/opencost/opencost-plugins/pull/38