cd /news/developer-tools/show-hn-rnet-oauth-python-python-lib… · home topics developer-tools article
[ARTICLE · art-29382] src=github.com ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

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.

read2 min views1 publishedJun 16, 2026

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()
pkce = auth.generate_pkce()
verifier = pkce['verifier']
challenge = pkce['challenge']

auth_url = auth.get_authorization_url(challenge, state='optional-state')
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()

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

openai_upload = ai.openai_file_upload(access_token, "gpt-4o", file_buffer, "application/pdf", "document.pdf")
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

── more in #developer-tools 4 stories · sorted by recency
── more on @rnet 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-rnet-oauth-p…] indexed:0 read:2min 2026-06-16 ·