Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ PADDLE_PRICE_PRO_YEARLY=
VITE_PADDLE_PRICE_PRO_MONTHLY="${PADDLE_PRICE_PRO_MONTHLY}"
VITE_PADDLE_PRICE_PRO_YEARLY="${PADDLE_PRICE_PRO_YEARLY}"

OPENROUTER_API_KEY=
OPENROUTER_MODEL=nvidia/nemotron-3-super-120b-a12b:free
PUTER_AUTH_TOKEN=
PUTER_MODEL=gpt-4o-mini
VITE_PUTER_MODEL="${PUTER_MODEL}"
20 changes: 8 additions & 12 deletions app/Services/AiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AiService
{
public function generateFullTheme(string $prompt): ?array
{
$apiKey = config('services.openrouter.key');
$apiKey = config('services.puter.key');

if (! $apiKey) {
return null;
Expand Down Expand Up @@ -42,10 +42,8 @@ public function generateFullTheme(string $prompt): ?array

$response = Http::withHeaders([
'Authorization' => 'Bearer '.$apiKey,
'HTTP-Referer' => config('app.url'),
'X-Title' => config('app.name'),
])->timeout(30)->post('https://openrouter.ai/api/v1/chat/completions', [
'model' => config('services.openrouter.model'),
])->timeout(30)->post('https://api.puter.com/puterai/openai/v1/chat/completions', [
'model' => config('services.puter.model'),
'messages' => [
['role' => 'system', 'content' => $systemPrompt],
['role' => 'user', 'content' => $prompt],
Expand All @@ -54,7 +52,7 @@ public function generateFullTheme(string $prompt): ?array
]);

if ($response->failed()) {
Log::warning('OpenRouter generateFullTheme failed', [
Log::warning('Puter generateFullTheme failed', [
'status' => $response->status(),
'body' => $response->body(),
]);
Expand Down Expand Up @@ -87,7 +85,7 @@ public function generateFullTheme(string $prompt): ?array
*/
public function generateThemeMetadata(string $name, array $colors): array
{
$apiKey = config('services.openrouter.key');
$apiKey = config('services.puter.key');

if (! $apiKey) {
return ['description' => null, 'tags' => []];
Expand All @@ -104,10 +102,8 @@ public function generateThemeMetadata(string $name, array $colors): array

$response = Http::withHeaders([
'Authorization' => 'Bearer '.$apiKey,
'HTTP-Referer' => config('app.url'),
'X-Title' => config('app.name'),
])->timeout(15)->post('https://openrouter.ai/api/v1/chat/completions', [
'model' => config('services.openrouter.model'),
])->timeout(15)->post('https://api.puter.com/puterai/openai/v1/chat/completions', [
'model' => config('services.puter.model'),
'messages' => [
[
'role' => 'user',
Expand All @@ -118,7 +114,7 @@ public function generateThemeMetadata(string $name, array $colors): array
]);

if ($response->failed()) {
Log::warning('OpenRouter generateThemeMetadata failed', [
Log::warning('Puter generateThemeMetadata failed', [
'status' => $response->status(),
'body' => $response->body(),
]);
Expand Down
5 changes: 5 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@
'model' => env('OPENROUTER_MODEL', 'openrouter/free'),
],

'puter' => [
'key' => env('PUTER_AUTH_TOKEN'),
'model' => env('PUTER_MODEL', 'gpt-4o-mini'),
],

];
182 changes: 182 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@vitejs/plugin-react": "^5.2.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"concurrently": "^9.2.1",
"culori": "^4.0.2",
"date-fns": "^4.1.0",
Expand Down
Loading
Loading