Skip to content

Commit 11f6d68

Browse files
authored
feat: preparation for OSS release, 0% fee and updated readme (#8)
* feat: preparation for OSS release, 0% fee and updated readme * feat: rename to just openrouter
1 parent 80544b7 commit 11f6d68

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

.actor/actor.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"actorSpecification": 1,
3-
"name": "actor-openrouter-proxy",
4-
"title": "OpenRouter Proxy",
5-
"description": "Proxy with pay per event pricing",
6-
"version": "0.0",
3+
"name": "openrouter",
4+
"title": "OpenRouter",
5+
"description": "You can use any AI LLM model without accounts in AI providers. Use this Actor as a proxy for all requests. Use pay-per-event pricing to pay only for the real credit used.",
6+
"version": "1.0",
77
"buildTag": "latest",
88
"usesStandbyMode": true,
99
"meta": {

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ This Apify Actor creates a proxy for the Open Router API, allowing you to access
99
- **Transparent billing**: Charges are applied to your Apify account at the same rates as Open Router
1010
- **Full feature support**: Supports both streaming and non-streaming responses
1111
- **No API key management**: Uses your Apify token for authentication - no need to manage separate Open Router API keys
12+
- **Standby mode**: Actor runs in standby mode only and has a static URL address, like a standard web server.
1213

1314
## Pricing
1415

15-
This Actor uses a pay-per-event pricing model through Apify. Each API request counts as one event. The underlying Open Router API costs are included in the per-event pricing, plus a 10% fee to cover the cost of running the proxy server.
16+
This Actor uses a pay-per-event pricing model through Apify. Each API request counts as one event, and no additional fees are applied beyond the standard Apify event pricing.
1617

1718
## Quick start
1819

@@ -28,7 +29,7 @@ npm install openai
2829
import OpenAI from 'openai';
2930

3031
const openai = new OpenAI({
31-
baseURL: 'https://michal-kalita--openrouter-proxy.apify.actor/api/v1',
32+
baseURL: 'https:/openrouter.apify.actor/api/v1',
3233
apiKey: 'no-key-required-but-must-not-be-empty', // Any non-empty string works; do NOT use a real API key.
3334
defaultHeaders: {
3435
Authorization: `Bearer ${process.env.APIFY_TOKEN}`, // Apify token is loaded automatically in runtime
@@ -74,6 +75,7 @@ for await (const chunk of stream) {
7475
## Available models
7576
7677
This proxy supports all models available through Open Router from providers including:
78+
7779
- OpenAI
7880
- Anthropic
7981
- Google

src/main.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ server.register(FastifyProxy, {
8585
}
8686

8787
let jsonString;
88-
const isStream = response.startsWith('data:') || response.startsWith(': OPENROUTER PROCESSING');
88+
// Stream must start with 'data:', but it's allowd to send just ":" to keep the connection alive
89+
const isStream = response.startsWith('data:') || response.startsWith(':');
8990
if (isStream) {
9091
request.log.info('Stream response mode');
9192
const lines = response.split('\n').filter((line) => line.trim());
@@ -109,9 +110,9 @@ server.register(FastifyProxy, {
109110
return;
110111
}
111112

112-
const costWithFee = cost * 1.1; // Add 10% fee
113-
const count = Math.max(Math.round(costWithFee / 0.0001), 1);
114-
request.log.info({ originalCost: cost, costWithFee }, `Charging $0.0001 x ${count} times`);
113+
// The Apify platform doesn't have a function for dynamic pricing. The price is calculated as a count of $0.0001 charges.
114+
const count = Math.max(Math.round(cost / 0.0001), 1);
115+
request.log.info({ cost }, `Charging $0.0001 x ${count} times`);
115116

116117
await Actor.charge({ eventName: 'credit-0-0001', count });
117118
},

0 commit comments

Comments
 (0)