ollama - 💡(How to fix) Fix Account Usage API Endpoint [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15132Fetched 2026-04-08 01:48:51
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
subscribed ×2closed ×1labeled ×1

Code Example

{                                                                                                                                                                           
    "session": {                                                                                                                                                              
      "used_percentage": 4.0,                                                                                                                                                 
      "resets_at": "2026-03-29T03:00:00Z"                                                                                                                                     
    },                                                 
    "weekly": {                            
      "used_percentage": 14.3,                                        
      "resets_at": "2026-03-30T02:00:00Z"                             
    },   
    "plan": "pro"        
  }
RAW_BUFFERClick to expand / collapse

Feature Request: Account Usage API Endpoint Subject: Add API endpoint to retrieve account usage/quota informaition

Problem Currently, there is no programmatic way to retrieve account usage information (session and weekly limits) for Ollama Cloud subscribers. Users must manually visit ollama.com/settings to check their usage. This makes it impossible to:

  • Monitor usage from CLI tools
  • Build menu bar apps that display usage
  • Automate usage tracking for teams

Proposed Solution Add a new API endpoint similar to Anthropic's /api/oauth/usage:

GET https://ollama.com/api/account/usage
Authorization: Bearer <api_key> Response:

  {                                                                                                                                                                           
    "session": {                                                                                                                                                              
      "used_percentage": 4.0,                                                                                                                                                 
      "resets_at": "2026-03-29T03:00:00Z"                                                                                                                                     
    },                                                 
    "weekly": {                            
      "used_percentage": 14.3,                                        
      "resets_at": "2026-03-30T02:00:00Z"                             
    },   
    "plan": "pro"        
  }

extent analysis

Fix Plan

To implement the proposed solution, we need to add a new API endpoint to retrieve account usage information.

Steps to Implement the Fix

  • Create a new API endpoint at /api/account/usage
  • Authenticate requests using the Authorization header with a Bearer token
  • Retrieve the user's account usage information from the database
  • Return the usage information in the proposed JSON format

Example Code (Node.js and Express)

const express = require('express');
const app = express();
const authenticate = require('./authenticate'); // assume authentication middleware

app.get('/api/account/usage', authenticate, (req, res) => {
  const userId = req.user.id;
  // Retrieve usage information from database
  const usage = {
    session: {
      used_percentage: calculateSessionUsage(userId),
      resets_at: getSessionResetTime(userId)
    },
    weekly: {
      used_percentage: calculateWeeklyUsage(userId),
      resets_at: getWeeklyResetTime(userId)
    },
    plan: getUserPlan(userId)
  };
  res.json(usage);
});

// Helper functions to calculate usage and reset times
function calculateSessionUsage(userId) {
  // implement logic to calculate session usage
}

function calculateWeeklyUsage(userId) {
  // implement logic to calculate weekly usage
}

function getSessionResetTime(userId) {
  // implement logic to get session reset time
}

function getWeeklyResetTime(userId) {
  // implement logic to get weekly reset time
}

function getUserPlan(userId) {
  // implement logic to get user plan
}

Verification

To verify the fix, send a GET request to the new endpoint with a valid API key and check that the response matches the proposed format. You can use a tool like curl or a REST client to test the endpoint. For example:

curl -X GET \
  https://ollama.com/api/account/usage \
  -H 'Authorization: Bearer <api_key>'

This should return the usage information in the proposed JSON format.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING