Show HN: Rnet-OAuth-Python – Python lib for user-funded AI API access A developer released Rnet-OAuth-Python, an open-source Python library that integrates RNet OAuth authentication with AI provider services, enabling users to pay for AI model token costs directly through their RNet accounts. The library supports OAuth2 PKCE, token management, user info retrieval, and AI chat with streaming and file upload capabilities for models like Gemini and GPT. A Python backend library for integrating RNet OAuth and AI Provider services. This library allows users to authenticate via RNet and pay for AI model token costs directly using their RNet account. OAuth2 PKCE Support : Secure authorization code flow with automatic code verifier and challenge generation. Token Management : Exchange authorization codes for tokens and refresh expired tokens. UserInfo Endpoint : Fetch the authenticated user's RNet profile with an access token. AI Integration : Easy methods to chat with AI models using standard or streaming responses. pip install rnet-oauth python from rnet oauth import RNetAuth, RNetAi auth = RNetAuth client id='client-id', client secret='client-secret', redirect uri='redirect-uri' ai = RNetAi 1. Generate PKCE pkce = auth.generate pkce verifier = pkce 'verifier' challenge = pkce 'challenge' 2. Get Authorization URL challenge: PKCE code challenge optional state: An optional string to maintain state between the request and callback recommended for security auth url = auth.get authorization url challenge, state='optional-state' 3. Exchange code for tokens tokens = auth.exchange code for token code, verifier access token = tokens 'access token' user info = auth.get user info access token print user info 'email' print user info 'name' The UserInfo response comes from RNet's /userinfo endpoint and may include: sub , email , email verified , name , preferred username , user id , role , and status . response = ai.chat { "contents": { "role": "user", "parts": {"text": "Hello "} } }, access token, "gemini-2.5-flash-lite" for chunk in ai.chat stream { "contents": { "role": "user", "parts": {"text": "Hello "} } }, access token, "gemini-2.5-flash-lite" : print chunk with open "document.pdf", "rb" as f: file buffer = f.read Upload to Gemini gemini upload = ai.gemini file upload access token, "gemini-2.5-flash-lite", file buffer, "application/pdf", "document.pdf" print gemini upload 'fileReference' Use this in chat payload Upload to OpenAI openai upload = ai.openai file upload access token, "gpt-4o", file buffer, "application/pdf", "document.pdf" Gemini files auto-delete after 48 hours, so there is no delete method. Delete an OpenAI file: ai.openai file delete access token, "gpt-4o", openai upload 'fileReference' payload = { "contents": { "role": "user", "parts": { "text": "Based on this document, what is my name? Also search the web for the current weather in London." }, { "fileData": { "fileUri": gemini upload 'fileReference' , "mimeType": gemini upload 'mimeType' } } } , "tools": { "googleSearch": {} } Enable Google Search tool } response = ai.chat payload, access token, "gemini-2.5-flash-lite" print response MIT