Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logic to track credit left #695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AnhChienVu
Copy link

@AnhChienVu AnhChienVu commented Oct 4, 2024

Fix #176
Hi, I implemented the logic to track the credit left. However, I couldn't integrate to the click send button.
I only made changes in use-cost.tsx file, it's a hook so you can use it at any time.
You need to set the API to be able fectch the data from OpenRouter:

const response = await fetch("https://openrouter.ai/api/v1/auth/key", {
        headers: {
          Authorization: `Bearer APIKey`,
        },
      });

It's not a fully integrated feature so just let me know any hints that I can enhance it.

@humphd
Copy link
Collaborator

humphd commented Oct 6, 2024

This can only work with the OpenRouter provider, so you'll need to deal with the user not having it selected as their current provider. You'll also need to get the API key from the settings, there's lots of existing code that does this in the tree for you to use.

Finally, we'll have to think about how this would get hooked into the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openrouter cost tracking
2 participants