Separating usage reporting and billing by project

Hi, I’m consulting as machine learning engineer to multiple clients. I’ve been exploring GPT-3 for a while for use on a project I’m working on for one client and pass GPT-3 costs transparently on to them as part of my R&D expenses.

I would now like to use GPT-3 in a project for another client also, but can’t seem to find a way to separate GPT-3 usage or billing on per-project basis.

Am I missing something? Is it possible at all to separate usage by API key, or to create another organisation associated with my account? Or is there another recommended way of going about this?

3 Likes

Thanks, appreciated.

Is it possible for organisations to register yet without significant and indefinite time on a waiting list? If so, that would definitely be first prize.

1 Like

Yes absolutely. Write to support@openai.com explaining the situation and we’ll find the appropriate solution!

3 Likes

Thanks, Boris, I’ll do that.

Since there is no official API / UI to see clearly billing, here’s a hack:

(open console option+cmd+i on Arc browser)

!curl 'https://api.openai.com/dashboard/billing/usage?end_date=2023-02-01&start_date=2023-01-01' \
  # ... WHATEVER
  --compressed > usage.json

d = json.load(open("usage.json"))

# compute price for "Base"
price_base = 0 # Base
price_embeddings = 0 # Embeddings
ft_training = 0 # FT Training
ft_inference = 0 # FT Inference
dalle = 0 # DALL-E API
for e in d["daily_costs"]:
    for b in e["line_items"]:
        if b["name"] == "Base":
            price_base += b["cost"]
        if b["name"] == "Embeddings":
            price_embeddings += b["cost"]
        if b["name"] == "FT Training":
            ft_training += b["cost"]
        if b["name"] == "FT Inference":
            ft_inference += b["cost"]
        if b["name"] == "DALL-E API":
            dalle += b["cost"]
print(f"Text generation price: {price_base}")
print(f"Embeddings price: {price_embeddings}")
print(f"FT Training price: {ft_training}")
print(f"FT Inference price: {ft_inference}")
print(f"DALL-E API price: {dalle}")

Thanks for taking the time to respond, Louis — appreciated.

OpenAI had resolved this issue for me by helping me to create different organisations for the various clients I consult to. While it still doesn’t help me to log expense by project, should I be working on multiple projects for a single client, it is good enough for my current needs.

I’ve had a look at your solution. It seems to allow one to break expenses down by date and service type. While this is potentially useful in certain contexts, it doesn’t resolve my original question about per-project usage reporting. Ideally, I would like the API to accept not only an organisation key, but also a project key or identifier, and then report usage on a per-project basis.

I suppose one can use the organisation functionality as a workaround and create multiple “organisations” for multiple projects for the same organisation.

My friend converted my code into an Arc Boost (using codex :p)

/* This runs after a web page loads */
// This will run in the background
const token = 'FILLME'
const org = 'FILLME'
const start_date = '2023-01-01'
const end_date = '2023-02-01'
const url = `https://api.openai.com/dashboard/billing/usage?end_date=${end_date}&start_date=${start_date}`;

fetch(url, {headers: {'authorization': `Bearer ${token}`, 'openai-organization': org}})
  .then(response => response.json())
  .then(data => {
    let price_base = 0; // Base
    let price_embeddings = 0; // Embeddings
    let ft_training = 0; // FT Training
    let ft_inference = 0; // FT Inference
    console.log(data)
    let dalle = 0; // DALL-E API
    for (const day of data.daily_costs) {
      for (const item of day.line_items) {
        if (item.name === "Base") {
          price_base += item.cost;
        }
        if (item.name === "Embeddings") {
          price_embeddings += item.cost;
        }
        if (item.name === "FT Training") {
          ft_training += item.cost;
        }
        if (item.name === "FT Inference") {
          ft_inference += item.cost;
        }
        if (item.name === "DALL-E API") {
          dalle += item.cost;
        }
      }
    }

    value = `Base: $${price_base/100} Embeddings: $${price_embeddings/100} FT Training: $${ft_training/100} FT Inference: ${ft_inference/100} DALL-E API: ${dalle/100}`
    el = document.createElement('div')
    el.innerText = value

  document.getElementsByClassName('usage-chart-header-right')[0].append(el)
  }).catch(e=> console.error(e))
;