Update hf.js
Browse files
hf.js
CHANGED
|
@@ -216,44 +216,37 @@ app.get('/', (req, res) => {
|
|
| 216 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 217 |
<title>Cursor To OpenAI</title>
|
| 218 |
<style>
|
| 219 |
-
/* Core Variables */
|
| 220 |
:root {
|
| 221 |
--bg-primary: #ffffff;
|
| 222 |
-
--bg-secondary: #
|
| 223 |
-
--bg-tertiary: #
|
| 224 |
-
--text-primary: #
|
| 225 |
-
--text-secondary: #
|
| 226 |
-
--border-color: #
|
| 227 |
--accent-color: #5D5CDE;
|
| 228 |
-
--accent-hover: #4a49c8;
|
| 229 |
--success-bg: #e1f5e1;
|
| 230 |
--success-border: #c3e6cb;
|
| 231 |
--warning-bg: #fff3cd;
|
| 232 |
--warning-border: #ffeeba;
|
| 233 |
-
--card-shadow: 0 2px
|
| 234 |
-
--hover-shadow: 0 5px 15px rgba(0,0,0,0.08);
|
| 235 |
-
--transition: all 0.2s ease-in-out;
|
| 236 |
}
|
| 237 |
|
| 238 |
[data-theme="dark"] {
|
| 239 |
-
--bg-primary: #
|
| 240 |
-
--bg-secondary: #
|
| 241 |
-
--bg-tertiary: #
|
| 242 |
-
--text-primary: #
|
| 243 |
-
--text-secondary: #
|
| 244 |
-
--border-color: #
|
| 245 |
--accent-color: #7D7CED;
|
| 246 |
-
--accent-hover: #9795f0;
|
| 247 |
--success-bg: #1e3a1e;
|
| 248 |
--success-border: #2a5a2a;
|
| 249 |
--warning-bg: #3a3018;
|
| 250 |
--warning-border: #5a4820;
|
| 251 |
-
--card-shadow: 0 2px
|
| 252 |
-
--hover-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
| 253 |
}
|
| 254 |
|
| 255 |
-
|
| 256 |
-
*, *::before, *::after {
|
| 257 |
box-sizing: border-box;
|
| 258 |
margin: 0;
|
| 259 |
padding: 0;
|
|
@@ -263,653 +256,376 @@ app.get('/', (req, res) => {
|
|
| 263 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 264 |
background-color: var(--bg-primary);
|
| 265 |
color: var(--text-primary);
|
| 266 |
-
line-height: 1.
|
| 267 |
-
transition:
|
| 268 |
-
padding:
|
| 269 |
-
overflow-x: hidden;
|
| 270 |
max-width: 100vw;
|
| 271 |
}
|
| 272 |
|
| 273 |
-
/* Typography */
|
| 274 |
h1, h2, h3, h4 {
|
| 275 |
-
margin: 0;
|
| 276 |
-
font-weight: 600;
|
| 277 |
-
line-height: 1.2;
|
| 278 |
-
}
|
| 279 |
-
|
| 280 |
-
h1 { font-size: 1.5rem; }
|
| 281 |
-
h2 { font-size: 1.25rem; }
|
| 282 |
-
h3 { font-size: 1.1rem; }
|
| 283 |
-
h4 { font-size: 1rem; }
|
| 284 |
-
|
| 285 |
-
/* Layout */
|
| 286 |
-
.dashboard {
|
| 287 |
-
display: grid;
|
| 288 |
-
grid-template-columns: 250px 1fr;
|
| 289 |
-
min-height: 100vh;
|
| 290 |
}
|
| 291 |
|
| 292 |
-
|
| 293 |
-
|
|
|
|
| 294 |
background: var(--bg-secondary);
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
flex-direction: column;
|
| 299 |
}
|
| 300 |
|
| 301 |
-
.
|
| 302 |
display: flex;
|
|
|
|
| 303 |
align-items: center;
|
| 304 |
-
|
| 305 |
-
padding-bottom: 1rem;
|
| 306 |
-
margin-bottom: 1rem;
|
| 307 |
border-bottom: 1px solid var(--border-color);
|
| 308 |
}
|
| 309 |
|
| 310 |
-
.
|
| 311 |
display: flex;
|
| 312 |
align-items: center;
|
| 313 |
-
padding: 0.5rem 0.75rem;
|
| 314 |
-
margin-bottom: 0.5rem;
|
| 315 |
-
border-radius: 6px;
|
| 316 |
-
cursor: pointer;
|
| 317 |
-
transition: var(--transition);
|
| 318 |
-
color: var(--text-secondary);
|
| 319 |
}
|
| 320 |
|
| 321 |
-
.
|
| 322 |
-
|
| 323 |
-
|
|
|
|
|
|
|
|
|
|
| 324 |
}
|
| 325 |
|
| 326 |
-
.
|
| 327 |
-
|
| 328 |
-
width:
|
| 329 |
-
|
| 330 |
}
|
| 331 |
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
}
|
| 338 |
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
}
|
| 346 |
|
| 347 |
-
.
|
| 348 |
-
|
| 349 |
-
border-radius: 8px;
|
| 350 |
-
padding: 1rem;
|
| 351 |
-
box-shadow: var(--card-shadow);
|
| 352 |
-
display: flex;
|
| 353 |
-
flex-direction: column;
|
| 354 |
}
|
| 355 |
|
| 356 |
-
.
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
|
|
|
| 360 |
}
|
| 361 |
|
| 362 |
-
.
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
|
|
|
| 366 |
overflow: hidden;
|
| 367 |
-
|
| 368 |
}
|
| 369 |
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
|
|
|
| 373 |
}
|
| 374 |
|
| 375 |
-
.
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
-
.
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
border: none;
|
| 385 |
-
border-bottom: 2px solid transparent;
|
| 386 |
color: var(--text-secondary);
|
| 387 |
-
|
| 388 |
-
font-weight: 500;
|
| 389 |
-
transition: var(--transition);
|
| 390 |
}
|
| 391 |
|
| 392 |
-
.
|
| 393 |
-
|
| 394 |
-
|
| 395 |
}
|
| 396 |
|
| 397 |
-
.
|
| 398 |
-
display:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 399 |
}
|
| 400 |
|
| 401 |
-
.
|
| 402 |
-
|
|
|
|
| 403 |
}
|
| 404 |
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
}
|
| 409 |
|
| 410 |
.models-grid {
|
| 411 |
display: flex;
|
| 412 |
flex-wrap: wrap;
|
| 413 |
-
gap:
|
| 414 |
-
max-height: 150px;
|
| 415 |
overflow-y: auto;
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
border-radius: 8px;
|
| 419 |
}
|
| 420 |
|
| 421 |
.model-tag {
|
| 422 |
background: var(--bg-secondary);
|
| 423 |
-
color: var(--text-primary);
|
| 424 |
border: 1px solid var(--border-color);
|
| 425 |
border-radius: 15px;
|
| 426 |
-
padding:
|
| 427 |
font-size: 0.8rem;
|
| 428 |
white-space: nowrap;
|
| 429 |
-
transition: var(--transition);
|
| 430 |
-
}
|
| 431 |
-
|
| 432 |
-
.model-tag:hover {
|
| 433 |
-
background: var(--accent-color);
|
| 434 |
-
color: white;
|
| 435 |
-
border-color: var(--accent-color);
|
| 436 |
-
transform: translateY(-2px);
|
| 437 |
-
box-shadow: var(--hover-shadow);
|
| 438 |
-
}
|
| 439 |
-
|
| 440 |
-
/* Setup Guide */
|
| 441 |
-
.guide-container {
|
| 442 |
-
padding: 1rem;
|
| 443 |
-
background: var(--bg-secondary);
|
| 444 |
-
border-radius: 8px;
|
| 445 |
}
|
| 446 |
|
| 447 |
.guide-steps {
|
| 448 |
display: flex;
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
|
|
|
| 453 |
}
|
| 454 |
|
| 455 |
.guide-step {
|
| 456 |
-
|
| 457 |
-
padding: 1rem;
|
| 458 |
-
background: var(--bg-tertiary);
|
| 459 |
border-radius: 8px;
|
|
|
|
| 460 |
border-left: 3px solid var(--accent-color);
|
| 461 |
-
flex: 1;
|
| 462 |
}
|
| 463 |
|
| 464 |
.guide-step h4 {
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
align-items: center;
|
| 468 |
}
|
| 469 |
|
| 470 |
-
.guide-step
|
| 471 |
-
|
| 472 |
-
align-items: center;
|
| 473 |
-
justify-content: center;
|
| 474 |
-
width: 24px;
|
| 475 |
-
height: 24px;
|
| 476 |
-
background: var(--accent-color);
|
| 477 |
-
color: white;
|
| 478 |
-
border-radius: 50%;
|
| 479 |
-
margin-right: 0.5rem;
|
| 480 |
-
font-size: 0.8rem;
|
| 481 |
}
|
| 482 |
|
| 483 |
.code-example {
|
| 484 |
-
margin-top:
|
| 485 |
background: var(--bg-primary);
|
| 486 |
-
padding:
|
| 487 |
-
border-radius:
|
| 488 |
font-family: monospace;
|
| 489 |
-
font-size: 0.
|
| 490 |
overflow-x: auto;
|
| 491 |
-
|
| 492 |
}
|
| 493 |
|
| 494 |
-
.
|
| 495 |
-
position: absolute;
|
| 496 |
-
top: 5px;
|
| 497 |
-
right: 5px;
|
| 498 |
-
background: var(--bg-secondary);
|
| 499 |
-
border: none;
|
| 500 |
-
border-radius: 4px;
|
| 501 |
-
width: 28px;
|
| 502 |
-
height: 28px;
|
| 503 |
display: flex;
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
cursor: pointer;
|
| 507 |
-
opacity: 0.7;
|
| 508 |
-
transition: var(--transition);
|
| 509 |
-
}
|
| 510 |
-
|
| 511 |
-
.copy-btn:hover {
|
| 512 |
-
opacity: 1;
|
| 513 |
-
background: var(--accent-color);
|
| 514 |
-
color: white;
|
| 515 |
-
}
|
| 516 |
-
|
| 517 |
-
/* Theme Toggle */
|
| 518 |
-
.theme-toggle {
|
| 519 |
-
margin-top: auto;
|
| 520 |
-
padding-top: 1rem;
|
| 521 |
-
display: flex;
|
| 522 |
-
align-items: center;
|
| 523 |
-
justify-content: space-between;
|
| 524 |
-
}
|
| 525 |
-
|
| 526 |
-
.toggle-switch {
|
| 527 |
-
position: relative;
|
| 528 |
-
display: inline-block;
|
| 529 |
-
width: 46px;
|
| 530 |
-
height: 24px;
|
| 531 |
}
|
| 532 |
|
| 533 |
-
.
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
|
|
|
| 537 |
}
|
| 538 |
|
| 539 |
-
.
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
top: 0;
|
| 543 |
-
left: 0;
|
| 544 |
-
right: 0;
|
| 545 |
-
bottom: 0;
|
| 546 |
-
background-color: var(--bg-tertiary);
|
| 547 |
-
transition: var(--transition);
|
| 548 |
-
border-radius: 24px;
|
| 549 |
}
|
| 550 |
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
height: 18px;
|
| 555 |
-
width: 18px;
|
| 556 |
-
left: 3px;
|
| 557 |
-
bottom: 3px;
|
| 558 |
-
background-color: var(--accent-color);
|
| 559 |
-
transition: var(--transition);
|
| 560 |
-
border-radius: 50%;
|
| 561 |
}
|
| 562 |
|
| 563 |
-
|
| 564 |
-
background
|
| 565 |
}
|
| 566 |
|
| 567 |
-
|
| 568 |
-
|
|
|
|
| 569 |
}
|
| 570 |
|
| 571 |
-
/* Responsive
|
| 572 |
@media (max-width: 768px) {
|
| 573 |
.dashboard {
|
| 574 |
-
|
| 575 |
-
}
|
| 576 |
-
|
| 577 |
-
.sidebar {
|
| 578 |
-
display: none;
|
| 579 |
}
|
| 580 |
|
| 581 |
-
.
|
| 582 |
-
|
| 583 |
-
position: fixed;
|
| 584 |
-
width: 250px;
|
| 585 |
-
height: 100vh;
|
| 586 |
-
z-index: 1000;
|
| 587 |
}
|
| 588 |
|
| 589 |
-
.
|
| 590 |
-
|
| 591 |
-
justify-content: space-between;
|
| 592 |
-
align-items: center;
|
| 593 |
-
padding: 1rem;
|
| 594 |
-
background: var(--bg-secondary);
|
| 595 |
-
box-shadow: var(--card-shadow);
|
| 596 |
-
}
|
| 597 |
-
|
| 598 |
-
.menu-toggle {
|
| 599 |
-
display: block;
|
| 600 |
-
background: none;
|
| 601 |
-
border: none;
|
| 602 |
-
color: var(--text-primary);
|
| 603 |
-
cursor: pointer;
|
| 604 |
-
font-size: 1.5rem;
|
| 605 |
-
}
|
| 606 |
-
}
|
| 607 |
-
|
| 608 |
-
@media (min-width: 769px) {
|
| 609 |
-
.mobile-header {
|
| 610 |
-
display: none;
|
| 611 |
}
|
| 612 |
}
|
| 613 |
</style>
|
| 614 |
</head>
|
| 615 |
<body>
|
| 616 |
-
<div class="
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
<button class="menu-toggle" id="menu-toggle">☰</button>
|
| 620 |
-
<h1>Cursor API</h1>
|
| 621 |
-
<div></div> <!-- Empty div for flexbox spacing -->
|
| 622 |
-
</div>
|
| 623 |
-
|
| 624 |
-
<!-- Sidebar -->
|
| 625 |
-
<aside class="sidebar" id="sidebar">
|
| 626 |
-
<div class="logo">
|
| 627 |
-
<h1>Cursor API</h1>
|
| 628 |
-
</div>
|
| 629 |
-
|
| 630 |
-
<div class="nav-item active" data-tab="dashboard">
|
| 631 |
-
<i>📊</i> Dashboard
|
| 632 |
-
</div>
|
| 633 |
-
<div class="nav-item" data-tab="models">
|
| 634 |
-
<i>🤖</i> Models
|
| 635 |
-
</div>
|
| 636 |
-
<div class="nav-item" data-tab="guide">
|
| 637 |
-
<i>📚</i> Integration Guide
|
| 638 |
-
</div>
|
| 639 |
-
<div class="nav-item" data-tab="tester">
|
| 640 |
-
<i>🧪</i> API Tester
|
| 641 |
-
</div>
|
| 642 |
-
|
| 643 |
-
<!-- Theme Toggle -->
|
| 644 |
<div class="theme-toggle">
|
| 645 |
-
|
| 646 |
-
<label class="
|
| 647 |
<input type="checkbox" id="theme-toggle">
|
| 648 |
-
<span class="
|
| 649 |
</label>
|
| 650 |
</div>
|
| 651 |
-
</
|
| 652 |
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
<
|
|
|
|
| 660 |
</div>
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
<
|
|
|
|
| 664 |
</div>
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 668 |
</div>
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
<
|
|
|
|
| 672 |
</div>
|
| 673 |
</div>
|
| 674 |
|
| 675 |
-
<!--
|
| 676 |
-
<div class="
|
| 677 |
-
<
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
<
|
| 681 |
-
<
|
|
|
|
|
|
|
| 682 |
</div>
|
| 683 |
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
<h2>Server Information</h2>
|
| 687 |
-
<div class="models-container">
|
| 688 |
-
<h3>Featured Models</h3>
|
| 689 |
-
<div class="models-grid" id="featured-models">
|
| 690 |
-
Loading...
|
| 691 |
-
</div>
|
| 692 |
-
</div>
|
| 693 |
-
|
| 694 |
-
<!-- Connection Guide Summary -->
|
| 695 |
-
<div class="guide-container">
|
| 696 |
-
<h3>Quick Start Guide</h3>
|
| 697 |
-
<div class="guide-steps">
|
| 698 |
-
<div class="guide-step">
|
| 699 |
-
<h4><span class="step-number">1</span>Authentication</h4>
|
| 700 |
-
<p>Get your Cursor cookie that starts with "user_..." from browser cookies after logging in to Cursor.</p>
|
| 701 |
-
</div>
|
| 702 |
-
<div class="guide-step">
|
| 703 |
-
<h4><span class="step-number">2</span>API Requests</h4>
|
| 704 |
-
<p>Send POST requests to <span id="endpoint-shorthand">Loading...</span> with your Cursor cookie as Bearer token.</p>
|
| 705 |
-
</div>
|
| 706 |
-
<div class="guide-step">
|
| 707 |
-
<h4><span class="step-number">3</span>Request Format</h4>
|
| 708 |
-
<p>Use OpenAI-compatible format with model, messages array, and optional parameters.</p>
|
| 709 |
-
</div>
|
| 710 |
-
</div>
|
| 711 |
-
</div>
|
| 712 |
</div>
|
| 713 |
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
</div>
|
| 720 |
|
| 721 |
-
<div class="
|
| 722 |
-
<
|
| 723 |
-
<
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
<div class="stat-card">
|
| 729 |
-
<div class="label">GPT Models</div>
|
| 730 |
-
<div class="value" id="gpt-count">-</div>
|
| 731 |
-
</div>
|
| 732 |
-
<div class="stat-card">
|
| 733 |
-
<div class="label">Gemini Models</div>
|
| 734 |
-
<div class="value" id="gemini-count">-</div>
|
| 735 |
-
</div>
|
| 736 |
-
<div class="stat-card">
|
| 737 |
-
<div class="label">Other Models</div>
|
| 738 |
-
<div class="value" id="other-count">-</div>
|
| 739 |
-
</div>
|
| 740 |
-
</div>
|
| 741 |
</div>
|
| 742 |
-
</div>
|
| 743 |
-
|
| 744 |
-
<!-- Integration Guide Tab -->
|
| 745 |
-
<div class="tab-content" id="guide-tab">
|
| 746 |
-
<h2>Integration Guide</h2>
|
| 747 |
|
| 748 |
-
<div class="guide-
|
| 749 |
-
<
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
<ol style="margin-left: 1rem; margin-top: 0.5rem;">
|
| 753 |
-
<li>Log in to <a href="https://cursor.so" target="_blank">Cursor.so</a></li>
|
| 754 |
-
<li>Open Developer Tools (F12)</li>
|
| 755 |
-
<li>Go to Application → Cookies</li>
|
| 756 |
-
<li>Find cookie with name starting with "user_"</li>
|
| 757 |
-
<li>Use this value as your API key</li>
|
| 758 |
-
</ol>
|
| 759 |
-
</div>
|
| 760 |
-
|
| 761 |
-
<div class="guide-step">
|
| 762 |
-
<h4><span class="step-number">2</span>API Configuration</h4>
|
| 763 |
-
<p>Set up your API client with:</p>
|
| 764 |
-
<ul style="margin-left: 1rem; margin-top: 0.5rem;">
|
| 765 |
-
<li>Base URL: <span id="endpoint-guide">Loading...</span></li>
|
| 766 |
-
<li>Headers:</li>
|
| 767 |
-
<div class="code-example">
|
| 768 |
-
Content-Type: application/json
|
| 769 |
-
Authorization: Bearer user_your_cookie_value
|
| 770 |
-
</div>
|
| 771 |
-
</ul>
|
| 772 |
-
</div>
|
| 773 |
-
|
| 774 |
-
<div class="guide-step">
|
| 775 |
-
<h4><span class="step-number">3</span>Making Requests</h4>
|
| 776 |
-
<p>Send chat completion requests:</p>
|
| 777 |
-
<div class="code-example">
|
| 778 |
-
POST /chat/completions
|
| 779 |
{
|
| 780 |
"model": "claude-3.7-sonnet",
|
| 781 |
"messages": [
|
| 782 |
{"role": "user", "content": "Hello!"}
|
| 783 |
],
|
| 784 |
"temperature": 0.7
|
| 785 |
-
}
|
| 786 |
-
<button class="copy-btn" title="Copy to clipboard">📋</button>
|
| 787 |
-
</div>
|
| 788 |
-
</div>
|
| 789 |
</div>
|
| 790 |
|
| 791 |
-
<div class="guide-
|
| 792 |
-
<
|
| 793 |
-
<div class="
|
| 794 |
-
<button class="tab-button active" data-code-tab="js">JavaScript</button>
|
| 795 |
-
<button class="tab-button" data-code-tab="python">Python</button>
|
| 796 |
-
<button class="tab-button" data-code-tab="curl">cURL</button>
|
| 797 |
-
</div>
|
| 798 |
-
|
| 799 |
-
<div class="code-tab active" id="js-code">
|
| 800 |
-
<div class="code-example">
|
| 801 |
-
const response = await fetch('${req.protocol}://${req.get('host')}/hf/v1/chat/completions', {
|
| 802 |
method: 'POST',
|
| 803 |
headers: {
|
| 804 |
'Content-Type': 'application/json',
|
| 805 |
-
'Authorization': 'Bearer
|
| 806 |
},
|
| 807 |
body: JSON.stringify({
|
| 808 |
model: 'claude-3.7-sonnet',
|
| 809 |
messages: [
|
| 810 |
-
{ role: 'user', content: 'Hello
|
| 811 |
],
|
| 812 |
temperature: 0.7
|
| 813 |
})
|
| 814 |
});
|
| 815 |
|
| 816 |
-
const data = await response.json()
|
| 817 |
-
console.log(data);
|
| 818 |
-
<button class="copy-btn" title="Copy to clipboard">📋</button>
|
| 819 |
-
</div>
|
| 820 |
-
</div>
|
| 821 |
-
|
| 822 |
-
<div class="code-tab" id="python-code">
|
| 823 |
-
<div class="code-example">
|
| 824 |
-
import requests
|
| 825 |
-
|
| 826 |
-
url = "${req.protocol}://${req.get('host')}/hf/v1/chat/completions"
|
| 827 |
-
headers = {
|
| 828 |
-
"Content-Type": "application/json",
|
| 829 |
-
"Authorization": "Bearer user_your_cookie_value"
|
| 830 |
-
}
|
| 831 |
-
payload = {
|
| 832 |
-
"model": "claude-3.7-sonnet",
|
| 833 |
-
"messages": [
|
| 834 |
-
{"role": "user", "content": "Hello, who are you?"}
|
| 835 |
-
],
|
| 836 |
-
"temperature": 0.7
|
| 837 |
-
}
|
| 838 |
-
|
| 839 |
-
response = requests.post(url, headers=headers, json=payload)
|
| 840 |
-
data = response.json()
|
| 841 |
-
print(data)
|
| 842 |
-
<button class="copy-btn" title="Copy to clipboard">📋</button>
|
| 843 |
-
</div>
|
| 844 |
-
</div>
|
| 845 |
-
|
| 846 |
-
<div class="code-tab" id="curl-code">
|
| 847 |
-
<div class="code-example">
|
| 848 |
-
curl -X POST "${req.protocol}://${req.get('host')}/hf/v1/chat/completions" \\
|
| 849 |
-
-H "Content-Type: application/json" \\
|
| 850 |
-
-H "Authorization: Bearer user_your_cookie_value" \\
|
| 851 |
-
-d '{
|
| 852 |
-
"model": "claude-3.7-sonnet",
|
| 853 |
-
"messages": [
|
| 854 |
-
{"role": "user", "content": "Hello, who are you?"}
|
| 855 |
-
],
|
| 856 |
-
"temperature": 0.7
|
| 857 |
-
}'
|
| 858 |
-
<button class="copy-btn" title="Copy to clipboard">📋</button>
|
| 859 |
-
</div>
|
| 860 |
-
</div>
|
| 861 |
-
</div>
|
| 862 |
-
</div>
|
| 863 |
-
|
| 864 |
-
<!-- API Tester Tab -->
|
| 865 |
-
<div class="tab-content" id="tester-tab">
|
| 866 |
-
<h2>API Tester</h2>
|
| 867 |
-
|
| 868 |
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem;">
|
| 869 |
-
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
| 870 |
-
<div class="guide-step">
|
| 871 |
-
<h4>Request</h4>
|
| 872 |
-
<div style="margin-top: 0.5rem;">
|
| 873 |
-
<label for="api-key" style="display: block; margin-bottom: 0.25rem;">API Key:</label>
|
| 874 |
-
<input type="password" id="api-key" placeholder="user_..." style="width: 100%; padding: 0.5rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary);">
|
| 875 |
-
</div>
|
| 876 |
-
|
| 877 |
-
<div style="margin-top: 0.5rem;">
|
| 878 |
-
<label for="model-select" style="display: block; margin-bottom: 0.25rem;">Model:</label>
|
| 879 |
-
<select id="model-select" style="width: 100%; padding: 0.5rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary);">
|
| 880 |
-
<option value="claude-3.7-sonnet">claude-3.7-sonnet</option>
|
| 881 |
-
</select>
|
| 882 |
-
</div>
|
| 883 |
-
|
| 884 |
-
<div style="margin-top: 0.5rem;">
|
| 885 |
-
<label for="prompt-input" style="display: block; margin-bottom: 0.25rem;">Prompt:</label>
|
| 886 |
-
<textarea id="prompt-input" placeholder="Enter your prompt here..." style="width: 100%; height: 120px; padding: 0.5rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary); resize: vertical;">Hello, can you introduce yourself?</textarea>
|
| 887 |
-
</div>
|
| 888 |
-
|
| 889 |
-
<div style="margin-top: 0.5rem; display: flex; gap: 0.5rem; align-items: center;">
|
| 890 |
-
<label for="temperature" style="flex-shrink: 0;">Temperature:</label>
|
| 891 |
-
<input type="range" id="temperature" min="0" max="1" step="0.1" value="0.7" style="flex-grow: 1;">
|
| 892 |
-
<span id="temperature-value">0.7</span>
|
| 893 |
-
</div>
|
| 894 |
-
|
| 895 |
-
<button id="submit-api" style="margin-top: 1rem; width: 100%; padding: 0.75rem; background: var(--accent-color); color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: 500; transition: var(--transition);">Send Request</button>
|
| 896 |
-
</div>
|
| 897 |
-
</div>
|
| 898 |
-
|
| 899 |
-
<div class="guide-step">
|
| 900 |
-
<h4>Response</h4>
|
| 901 |
-
<div style="height: 300px; overflow-y: auto; margin-top: 0.5rem; padding: 0.75rem; background: var(--bg-tertiary); border-radius: 4px; font-family: monospace; white-space: pre-wrap; font-size: 0.8rem;" id="api-response">
|
| 902 |
-
Response will appear here...
|
| 903 |
-
</div>
|
| 904 |
-
</div>
|
| 905 |
</div>
|
| 906 |
</div>
|
| 907 |
</div>
|
| 908 |
-
</
|
| 909 |
</div>
|
| 910 |
|
| 911 |
<script>
|
| 912 |
-
// Theme
|
| 913 |
const themeToggle = document.getElementById('theme-toggle');
|
| 914 |
|
| 915 |
// Check system preference
|
|
@@ -918,7 +634,7 @@ curl -X POST "${req.protocol}://${req.get('host')}/hf/v1/chat/completions" \\
|
|
| 918 |
themeToggle.checked = true;
|
| 919 |
}
|
| 920 |
|
| 921 |
-
// Toggle theme
|
| 922 |
themeToggle.addEventListener('change', function() {
|
| 923 |
if (this.checked) {
|
| 924 |
document.documentElement.setAttribute('data-theme', 'dark');
|
|
@@ -927,102 +643,53 @@ curl -X POST "${req.protocol}://${req.get('host')}/hf/v1/chat/completions" \\
|
|
| 927 |
}
|
| 928 |
});
|
| 929 |
|
| 930 |
-
//
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
|
|
|
| 939 |
|
| 940 |
-
//
|
| 941 |
-
const
|
| 942 |
-
const
|
| 943 |
-
const navItems = document.querySelectorAll('.nav-item');
|
| 944 |
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
tabContents.forEach(content => content.classList.remove('active'));
|
| 949 |
-
navItems.forEach(item => item.classList.remove('active'));
|
| 950 |
-
|
| 951 |
-
// Activate the selected tab
|
| 952 |
-
document.querySelector(`.tab-button[data-tab="${tabId}"]`)?.classList.add('active');
|
| 953 |
-
document.getElementById(`${tabId}-tab`)?.classList.add('active');
|
| 954 |
-
document.querySelector(`.nav-item[data-tab="${tabId}"]`)?.classList.add('active');
|
| 955 |
}
|
| 956 |
|
| 957 |
-
//
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
const tabId = this.getAttribute('data-tab');
|
| 961 |
-
setActiveTab(tabId);
|
| 962 |
-
});
|
| 963 |
-
});
|
| 964 |
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
|
|
|
| 970 |
|
| 971 |
-
//
|
| 972 |
-
|
| 973 |
-
|
| 974 |
}
|
| 975 |
-
});
|
| 976 |
-
});
|
| 977 |
-
|
| 978 |
-
// Code example tabs
|
| 979 |
-
const codeTabButtons = document.querySelectorAll('[data-code-tab]');
|
| 980 |
-
const codeTabs = document.querySelectorAll('.code-tab');
|
| 981 |
-
|
| 982 |
-
codeTabButtons.forEach(button => {
|
| 983 |
-
button.addEventListener('click', function() {
|
| 984 |
-
codeTabButtons.forEach(btn => btn.classList.remove('active'));
|
| 985 |
-
codeTabs.forEach(tab => tab.classList.remove('active'));
|
| 986 |
|
| 987 |
-
|
| 988 |
this.classList.add('active');
|
| 989 |
-
document.getElementById(`${tabId}-code`).classList.add('active');
|
| 990 |
-
});
|
| 991 |
-
});
|
| 992 |
-
|
| 993 |
-
// Copy buttons
|
| 994 |
-
document.querySelectorAll('.copy-btn').forEach(button => {
|
| 995 |
-
button.addEventListener('click', function() {
|
| 996 |
-
const codeBlock = this.parentElement;
|
| 997 |
-
const code = codeBlock.textContent.trim();
|
| 998 |
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
})
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
// Get and display endpoint URL
|
| 1009 |
-
const url = new URL(window.location.href);
|
| 1010 |
-
const link = url.protocol + '//' + url.host + '/hf/v1';
|
| 1011 |
-
|
| 1012 |
-
// Update all endpoint URL displays
|
| 1013 |
-
document.querySelectorAll('#endpoint-url, #endpoint-guide').forEach(el => {
|
| 1014 |
-
el.textContent = link;
|
| 1015 |
-
});
|
| 1016 |
-
|
| 1017 |
-
document.getElementById('endpoint-shorthand').textContent = link + '/chat/completions';
|
| 1018 |
-
|
| 1019 |
-
// Temperature slider
|
| 1020 |
-
const temperatureSlider = document.getElementById('temperature');
|
| 1021 |
-
const temperatureValue = document.getElementById('temperature-value');
|
| 1022 |
-
|
| 1023 |
-
if (temperatureSlider) {
|
| 1024 |
-
temperatureSlider.addEventListener('input', function() {
|
| 1025 |
-
temperatureValue.textContent = this.value;
|
| 1026 |
});
|
| 1027 |
}
|
| 1028 |
|
|
@@ -1030,101 +697,45 @@ curl -X POST "${req.protocol}://${req.get('host')}/hf/v1/chat/completions" \\
|
|
| 1030 |
fetch('/hf/v1/models')
|
| 1031 |
.then(response => response.json())
|
| 1032 |
.then(data => {
|
| 1033 |
-
//
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
// Count models by category
|
| 1037 |
-
let claudeCount = 0;
|
| 1038 |
-
let gptCount = 0;
|
| 1039 |
-
let geminiCount = 0;
|
| 1040 |
-
let otherCount = 0;
|
| 1041 |
-
|
| 1042 |
-
data.data.forEach(model => {
|
| 1043 |
-
if (model.id.includes('claude')) claudeCount++;
|
| 1044 |
-
else if (model.id.includes('gpt')) gptCount++;
|
| 1045 |
-
else if (model.id.includes('gemini')) geminiCount++;
|
| 1046 |
-
else otherCount++;
|
| 1047 |
-
});
|
| 1048 |
-
|
| 1049 |
-
document.getElementById('claude-count').textContent = claudeCount;
|
| 1050 |
-
document.getElementById('gpt-count').textContent = gptCount;
|
| 1051 |
-
document.getElementById('gemini-count').textContent = geminiCount;
|
| 1052 |
-
document.getElementById('other-count').textContent = otherCount;
|
| 1053 |
-
|
| 1054 |
-
// Featured models (for dashboard)
|
| 1055 |
-
const featuredModels = ['claude-3.7-sonnet', 'gpt-4o', 'claude-3.5-sonnet', 'gemini-1.5-flash-500k'];
|
| 1056 |
-
const featuredContainer = document.getElementById('featured-models');
|
| 1057 |
-
featuredContainer.innerHTML = '';
|
| 1058 |
-
|
| 1059 |
-
featuredModels.forEach(modelId => {
|
| 1060 |
-
const found = data.data.find(m => m.id === modelId);
|
| 1061 |
-
if (found) {
|
| 1062 |
-
const modelEl = document.createElement('div');
|
| 1063 |
-
modelEl.className = 'model-tag';
|
| 1064 |
-
modelEl.textContent = found.id;
|
| 1065 |
-
featuredContainer.appendChild(modelEl);
|
| 1066 |
-
}
|
| 1067 |
});
|
| 1068 |
|
| 1069 |
-
|
| 1070 |
-
const
|
| 1071 |
-
|
|
|
|
| 1072 |
|
| 1073 |
-
//
|
| 1074 |
-
|
|
|
|
|
|
|
|
|
|
| 1075 |
|
| 1076 |
-
data.data.forEach(model
|
|
|
|
| 1077 |
const modelEl = document.createElement('div');
|
| 1078 |
modelEl.className = 'model-tag';
|
| 1079 |
modelEl.textContent = model.id;
|
| 1080 |
-
allModelsContainer.appendChild(modelEl);
|
| 1081 |
|
| 1082 |
-
// Add to
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1087 |
});
|
| 1088 |
})
|
| 1089 |
-
.catch(err
|
| 1090 |
-
document.
|
| 1091 |
-
|
| 1092 |
-
});
|
| 1093 |
});
|
| 1094 |
-
|
| 1095 |
-
// API Tester
|
| 1096 |
-
const submitApiBtn = document.getElementById('submit-api');
|
| 1097 |
-
if (submitApiBtn) {
|
| 1098 |
-
submitApiBtn.addEventListener('click', async function() {
|
| 1099 |
-
const apiKey = document.getElementById('api-key').value;
|
| 1100 |
-
const model = document.getElementById('model-select').value;
|
| 1101 |
-
const prompt = document.getElementById('prompt-input').value;
|
| 1102 |
-
const temperature = parseFloat(document.getElementById('temperature').value);
|
| 1103 |
-
|
| 1104 |
-
const responseContainer = document.getElementById('api-response');
|
| 1105 |
-
responseContainer.textContent = 'Loading...';
|
| 1106 |
-
|
| 1107 |
-
try {
|
| 1108 |
-
const response = await fetch(`${link}/chat/completions`, {
|
| 1109 |
-
method: 'POST',
|
| 1110 |
-
headers: {
|
| 1111 |
-
'Content-Type': 'application/json',
|
| 1112 |
-
'Authorization': `Bearer ${apiKey}`
|
| 1113 |
-
},
|
| 1114 |
-
body: JSON.stringify({
|
| 1115 |
-
model: model,
|
| 1116 |
-
messages: [{ role: 'user', content: prompt }],
|
| 1117 |
-
temperature: temperature
|
| 1118 |
-
})
|
| 1119 |
-
});
|
| 1120 |
-
|
| 1121 |
-
const data = await response.json();
|
| 1122 |
-
responseContainer.textContent = JSON.stringify(data, null, 2);
|
| 1123 |
-
} catch (error) {
|
| 1124 |
-
responseContainer.textContent = 'Error: ' + (error.message || 'Unknown error');
|
| 1125 |
-
}
|
| 1126 |
-
});
|
| 1127 |
-
}
|
| 1128 |
</script>
|
| 1129 |
</body>
|
| 1130 |
</html>
|
|
|
|
| 216 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 217 |
<title>Cursor To OpenAI</title>
|
| 218 |
<style>
|
|
|
|
| 219 |
:root {
|
| 220 |
--bg-primary: #ffffff;
|
| 221 |
+
--bg-secondary: #f9f9f9;
|
| 222 |
+
--bg-tertiary: #f0f0f0;
|
| 223 |
+
--text-primary: #333333;
|
| 224 |
+
--text-secondary: #666666;
|
| 225 |
+
--border-color: #e0e0e0;
|
| 226 |
--accent-color: #5D5CDE;
|
|
|
|
| 227 |
--success-bg: #e1f5e1;
|
| 228 |
--success-border: #c3e6cb;
|
| 229 |
--warning-bg: #fff3cd;
|
| 230 |
--warning-border: #ffeeba;
|
| 231 |
+
--card-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
|
|
|
|
|
| 232 |
}
|
| 233 |
|
| 234 |
[data-theme="dark"] {
|
| 235 |
+
--bg-primary: #181818;
|
| 236 |
+
--bg-secondary: #222222;
|
| 237 |
+
--bg-tertiary: #2a2a2a;
|
| 238 |
+
--text-primary: #e0e0e0;
|
| 239 |
+
--text-secondary: #b0b0b0;
|
| 240 |
+
--border-color: #444444;
|
| 241 |
--accent-color: #7D7CED;
|
|
|
|
| 242 |
--success-bg: #1e3a1e;
|
| 243 |
--success-border: #2a5a2a;
|
| 244 |
--warning-bg: #3a3018;
|
| 245 |
--warning-border: #5a4820;
|
| 246 |
+
--card-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
|
|
|
| 247 |
}
|
| 248 |
|
| 249 |
+
* {
|
|
|
|
| 250 |
box-sizing: border-box;
|
| 251 |
margin: 0;
|
| 252 |
padding: 0;
|
|
|
|
| 256 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 257 |
background-color: var(--bg-primary);
|
| 258 |
color: var(--text-primary);
|
| 259 |
+
line-height: 1.6;
|
| 260 |
+
transition: background-color 0.3s, color 0.3s;
|
| 261 |
+
padding: 20px;
|
|
|
|
| 262 |
max-width: 100vw;
|
| 263 |
}
|
| 264 |
|
|
|
|
| 265 |
h1, h2, h3, h4 {
|
| 266 |
+
margin-bottom: 0.5rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
}
|
| 268 |
|
| 269 |
+
.container {
|
| 270 |
+
max-width: 1200px;
|
| 271 |
+
margin: 0 auto;
|
| 272 |
background: var(--bg-secondary);
|
| 273 |
+
border-radius: 10px;
|
| 274 |
+
box-shadow: var(--card-shadow);
|
| 275 |
+
overflow: hidden;
|
|
|
|
| 276 |
}
|
| 277 |
|
| 278 |
+
.header {
|
| 279 |
display: flex;
|
| 280 |
+
justify-content: space-between;
|
| 281 |
align-items: center;
|
| 282 |
+
padding: 15px 20px;
|
|
|
|
|
|
|
| 283 |
border-bottom: 1px solid var(--border-color);
|
| 284 |
}
|
| 285 |
|
| 286 |
+
.theme-toggle {
|
| 287 |
display: flex;
|
| 288 |
align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
}
|
| 290 |
|
| 291 |
+
.switch {
|
| 292 |
+
position: relative;
|
| 293 |
+
display: inline-block;
|
| 294 |
+
width: 50px;
|
| 295 |
+
height: 24px;
|
| 296 |
+
margin-left: 10px;
|
| 297 |
}
|
| 298 |
|
| 299 |
+
.switch input {
|
| 300 |
+
opacity: 0;
|
| 301 |
+
width: 0;
|
| 302 |
+
height: 0;
|
| 303 |
}
|
| 304 |
|
| 305 |
+
.slider {
|
| 306 |
+
position: absolute;
|
| 307 |
+
cursor: pointer;
|
| 308 |
+
top: 0;
|
| 309 |
+
left: 0;
|
| 310 |
+
right: 0;
|
| 311 |
+
bottom: 0;
|
| 312 |
+
background-color: var(--bg-tertiary);
|
| 313 |
+
transition: .4s;
|
| 314 |
+
border-radius: 24px;
|
| 315 |
}
|
| 316 |
|
| 317 |
+
.slider:before {
|
| 318 |
+
position: absolute;
|
| 319 |
+
content: "";
|
| 320 |
+
height: 16px;
|
| 321 |
+
width: 16px;
|
| 322 |
+
left: 4px;
|
| 323 |
+
bottom: 4px;
|
| 324 |
+
background-color: var(--accent-color);
|
| 325 |
+
transition: .4s;
|
| 326 |
+
border-radius: 50%;
|
| 327 |
}
|
| 328 |
|
| 329 |
+
input:checked + .slider:before {
|
| 330 |
+
transform: translateX(26px);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
}
|
| 332 |
|
| 333 |
+
.dashboard {
|
| 334 |
+
display: flex;
|
| 335 |
+
flex-wrap: wrap;
|
| 336 |
+
padding: 20px;
|
| 337 |
+
gap: 20px;
|
| 338 |
}
|
| 339 |
|
| 340 |
+
.server-info, .models-section, .guide-section {
|
| 341 |
+
flex: 1 1 300px;
|
| 342 |
+
background: var(--bg-tertiary);
|
| 343 |
+
border-radius: 8px;
|
| 344 |
+
padding: 15px;
|
| 345 |
overflow: hidden;
|
| 346 |
+
max-height: 500px;
|
| 347 |
}
|
| 348 |
|
| 349 |
+
.server-info {
|
| 350 |
+
display: flex;
|
| 351 |
+
flex-direction: column;
|
| 352 |
+
gap: 10px;
|
| 353 |
}
|
| 354 |
|
| 355 |
+
.info-item {
|
| 356 |
+
padding: 10px;
|
| 357 |
+
background: var(--bg-secondary);
|
| 358 |
+
border-radius: 6px;
|
| 359 |
+
margin-bottom: 5px;
|
| 360 |
}
|
| 361 |
|
| 362 |
+
.info-item strong {
|
| 363 |
+
display: block;
|
| 364 |
+
font-size: 0.8rem;
|
|
|
|
|
|
|
| 365 |
color: var(--text-secondary);
|
| 366 |
+
margin-bottom: 3px;
|
|
|
|
|
|
|
| 367 |
}
|
| 368 |
|
| 369 |
+
.info-item span {
|
| 370 |
+
font-size: 0.9rem;
|
| 371 |
+
word-break: break-all;
|
| 372 |
}
|
| 373 |
|
| 374 |
+
.status-badge {
|
| 375 |
+
display: inline-block;
|
| 376 |
+
padding: 3px 8px;
|
| 377 |
+
border-radius: 12px;
|
| 378 |
+
font-size: 0.8rem;
|
| 379 |
+
font-weight: 500;
|
| 380 |
}
|
| 381 |
|
| 382 |
+
.status-enabled {
|
| 383 |
+
background: var(--success-bg);
|
| 384 |
+
color: var(--success-border);
|
| 385 |
}
|
| 386 |
|
| 387 |
+
.status-disabled {
|
| 388 |
+
background: var(--warning-bg);
|
| 389 |
+
color: var(--warning-border);
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
.section-header {
|
| 393 |
+
margin-bottom: 15px;
|
| 394 |
+
font-size: 1rem;
|
| 395 |
}
|
| 396 |
|
| 397 |
.models-grid {
|
| 398 |
display: flex;
|
| 399 |
flex-wrap: wrap;
|
| 400 |
+
gap: 5px;
|
|
|
|
| 401 |
overflow-y: auto;
|
| 402 |
+
max-height: 435px;
|
| 403 |
+
padding-right: 5px;
|
|
|
|
| 404 |
}
|
| 405 |
|
| 406 |
.model-tag {
|
| 407 |
background: var(--bg-secondary);
|
|
|
|
| 408 |
border: 1px solid var(--border-color);
|
| 409 |
border-radius: 15px;
|
| 410 |
+
padding: 4px 10px;
|
| 411 |
font-size: 0.8rem;
|
| 412 |
white-space: nowrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
}
|
| 414 |
|
| 415 |
.guide-steps {
|
| 416 |
display: flex;
|
| 417 |
+
flex-direction: column;
|
| 418 |
+
gap: 10px;
|
| 419 |
+
overflow-y: auto;
|
| 420 |
+
max-height: 435px;
|
| 421 |
+
padding-right: 5px;
|
| 422 |
}
|
| 423 |
|
| 424 |
.guide-step {
|
| 425 |
+
background: var(--bg-secondary);
|
|
|
|
|
|
|
| 426 |
border-radius: 8px;
|
| 427 |
+
padding: 10px;
|
| 428 |
border-left: 3px solid var(--accent-color);
|
|
|
|
| 429 |
}
|
| 430 |
|
| 431 |
.guide-step h4 {
|
| 432 |
+
font-size: 0.9rem;
|
| 433 |
+
margin-bottom: 5px;
|
|
|
|
| 434 |
}
|
| 435 |
|
| 436 |
+
.guide-step p {
|
| 437 |
+
font-size: 0.85rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
}
|
| 439 |
|
| 440 |
.code-example {
|
| 441 |
+
margin-top: 8px;
|
| 442 |
background: var(--bg-primary);
|
| 443 |
+
padding: 8px;
|
| 444 |
+
border-radius: 4px;
|
| 445 |
font-family: monospace;
|
| 446 |
+
font-size: 0.75rem;
|
| 447 |
overflow-x: auto;
|
| 448 |
+
white-space: pre;
|
| 449 |
}
|
| 450 |
|
| 451 |
+
.tabs {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
display: flex;
|
| 453 |
+
border-bottom: 1px solid var(--border-color);
|
| 454 |
+
margin-bottom: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
}
|
| 456 |
|
| 457 |
+
.tab {
|
| 458 |
+
padding: 8px 15px;
|
| 459 |
+
cursor: pointer;
|
| 460 |
+
font-size: 0.85rem;
|
| 461 |
+
border-bottom: 2px solid transparent;
|
| 462 |
}
|
| 463 |
|
| 464 |
+
.tab.active {
|
| 465 |
+
color: var(--accent-color);
|
| 466 |
+
border-bottom-color: var(--accent-color);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
}
|
| 468 |
|
| 469 |
+
/* Scrollbar styling */
|
| 470 |
+
.models-grid::-webkit-scrollbar, .guide-steps::-webkit-scrollbar {
|
| 471 |
+
width: 6px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 472 |
}
|
| 473 |
|
| 474 |
+
.models-grid::-webkit-scrollbar-track, .guide-steps::-webkit-scrollbar-track {
|
| 475 |
+
background: var(--bg-tertiary);
|
| 476 |
}
|
| 477 |
|
| 478 |
+
.models-grid::-webkit-scrollbar-thumb, .guide-steps::-webkit-scrollbar-thumb {
|
| 479 |
+
background-color: var(--border-color);
|
| 480 |
+
border-radius: 6px;
|
| 481 |
}
|
| 482 |
|
| 483 |
+
/* Responsive adjustments */
|
| 484 |
@media (max-width: 768px) {
|
| 485 |
.dashboard {
|
| 486 |
+
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
}
|
| 488 |
|
| 489 |
+
.server-info, .models-section, .guide-section {
|
| 490 |
+
max-height: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
}
|
| 492 |
|
| 493 |
+
.models-grid, .guide-steps {
|
| 494 |
+
max-height: 200px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
}
|
| 496 |
}
|
| 497 |
</style>
|
| 498 |
</head>
|
| 499 |
<body>
|
| 500 |
+
<div class="container">
|
| 501 |
+
<div class="header">
|
| 502 |
+
<h1>Cursor To OpenAI Server</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
<div class="theme-toggle">
|
| 504 |
+
Dark Mode
|
| 505 |
+
<label class="switch">
|
| 506 |
<input type="checkbox" id="theme-toggle">
|
| 507 |
+
<span class="slider"></span>
|
| 508 |
</label>
|
| 509 |
</div>
|
| 510 |
+
</div>
|
| 511 |
|
| 512 |
+
<div class="dashboard">
|
| 513 |
+
<!-- Server Information -->
|
| 514 |
+
<div class="server-info">
|
| 515 |
+
<h3 class="section-header">Server Information</h3>
|
| 516 |
+
|
| 517 |
+
<div class="info-item">
|
| 518 |
+
<strong>API Endpoint</strong>
|
| 519 |
+
<span id="endpoint-url">Loading...</span>
|
| 520 |
</div>
|
| 521 |
+
|
| 522 |
+
<div class="info-item">
|
| 523 |
+
<strong>Authentication</strong>
|
| 524 |
+
<span>Cursor Cookie (user_...)</span>
|
| 525 |
</div>
|
| 526 |
+
|
| 527 |
+
<div class="info-item">
|
| 528 |
+
<strong>Proxy Status</strong>
|
| 529 |
+
<span>
|
| 530 |
+
<span class="status-badge ${proxyConfig ? 'status-enabled' : 'status-disabled'}">
|
| 531 |
+
${proxyConfig ? 'Enabled' : 'Disabled'}
|
| 532 |
+
</span>
|
| 533 |
+
${proxyConfig ? `<div style="margin-top:5px">Server: ${proxyConfig.host}:${proxyConfig.port}</div>` : ''}
|
| 534 |
+
</span>
|
| 535 |
</div>
|
| 536 |
+
|
| 537 |
+
<div class="info-item">
|
| 538 |
+
<strong>Usage</strong>
|
| 539 |
+
<span>Send requests to the endpoint with your Cursor cookie as the Bearer token in the Authorization header.</span>
|
| 540 |
</div>
|
| 541 |
</div>
|
| 542 |
|
| 543 |
+
<!-- Models Section -->
|
| 544 |
+
<div class="models-section">
|
| 545 |
+
<h3 class="section-header">Supported Models</h3>
|
| 546 |
+
|
| 547 |
+
<div class="tabs">
|
| 548 |
+
<div class="tab active" data-models-tab="all">All Models</div>
|
| 549 |
+
<div class="tab" data-models-tab="claude">Claude</div>
|
| 550 |
+
<div class="tab" data-models-tab="gpt">GPT</div>
|
| 551 |
+
<div class="tab" data-models-tab="other">Other</div>
|
| 552 |
</div>
|
| 553 |
|
| 554 |
+
<div id="all-models" class="models-grid tab-content active">
|
| 555 |
+
Loading models...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
</div>
|
| 557 |
|
| 558 |
+
<div id="claude-models" class="models-grid tab-content">
|
| 559 |
+
Loading Claude models...
|
| 560 |
+
</div>
|
| 561 |
+
|
| 562 |
+
<div id="gpt-models" class="models-grid tab-content">
|
| 563 |
+
Loading GPT models...
|
| 564 |
+
</div>
|
| 565 |
+
|
| 566 |
+
<div id="other-models" class="models-grid tab-content">
|
| 567 |
+
Loading other models...
|
| 568 |
+
</div>
|
| 569 |
+
</div>
|
| 570 |
+
|
| 571 |
+
<!-- Integration Guide -->
|
| 572 |
+
<div class="guide-section">
|
| 573 |
+
<h3 class="section-header">Integration Guide</h3>
|
| 574 |
+
|
| 575 |
+
<div class="guide-steps">
|
| 576 |
+
<div class="guide-step">
|
| 577 |
+
<h4>1. Authentication</h4>
|
| 578 |
+
<p>Obtain your Cursor cookie that starts with "user_..." from browser cookies after logging in to Cursor.</p>
|
| 579 |
</div>
|
| 580 |
|
| 581 |
+
<div class="guide-step">
|
| 582 |
+
<h4>2. API Configuration</h4>
|
| 583 |
+
<p>Set up your API client with:</p>
|
| 584 |
+
<p><strong>Base URL:</strong> <span id="endpoint-guide">Loading...</span></p>
|
| 585 |
+
<p><strong>Headers:</strong></p>
|
| 586 |
+
<div class="code-example">Content-Type: application/json
|
| 587 |
+
Authorization: Bearer user_your_cookie</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 588 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 589 |
|
| 590 |
+
<div class="guide-step">
|
| 591 |
+
<h4>3. Making Requests</h4>
|
| 592 |
+
<p>Send chat completion requests:</p>
|
| 593 |
+
<div class="code-example">POST /chat/completions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
{
|
| 595 |
"model": "claude-3.7-sonnet",
|
| 596 |
"messages": [
|
| 597 |
{"role": "user", "content": "Hello!"}
|
| 598 |
],
|
| 599 |
"temperature": 0.7
|
| 600 |
+
}</div>
|
|
|
|
|
|
|
|
|
|
| 601 |
</div>
|
| 602 |
|
| 603 |
+
<div class="guide-step">
|
| 604 |
+
<h4>4. Code Example</h4>
|
| 605 |
+
<div class="code-example">const response = await fetch('${req.protocol}://${req.get('host')}/hf/v1/chat/completions', {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
method: 'POST',
|
| 607 |
headers: {
|
| 608 |
'Content-Type': 'application/json',
|
| 609 |
+
'Authorization': 'Bearer user_your_cookie'
|
| 610 |
},
|
| 611 |
body: JSON.stringify({
|
| 612 |
model: 'claude-3.7-sonnet',
|
| 613 |
messages: [
|
| 614 |
+
{ role: 'user', content: 'Hello' }
|
| 615 |
],
|
| 616 |
temperature: 0.7
|
| 617 |
})
|
| 618 |
});
|
| 619 |
|
| 620 |
+
const data = await response.json();</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
</div>
|
| 622 |
</div>
|
| 623 |
</div>
|
| 624 |
+
</div>
|
| 625 |
</div>
|
| 626 |
|
| 627 |
<script>
|
| 628 |
+
// Theme toggling
|
| 629 |
const themeToggle = document.getElementById('theme-toggle');
|
| 630 |
|
| 631 |
// Check system preference
|
|
|
|
| 634 |
themeToggle.checked = true;
|
| 635 |
}
|
| 636 |
|
| 637 |
+
// Toggle theme when switch is clicked
|
| 638 |
themeToggle.addEventListener('change', function() {
|
| 639 |
if (this.checked) {
|
| 640 |
document.documentElement.setAttribute('data-theme', 'dark');
|
|
|
|
| 643 |
}
|
| 644 |
});
|
| 645 |
|
| 646 |
+
// Listen for system theme changes
|
| 647 |
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
| 648 |
+
if (event.matches) {
|
| 649 |
+
document.documentElement.setAttribute('data-theme', 'dark');
|
| 650 |
+
themeToggle.checked = true;
|
| 651 |
+
} else {
|
| 652 |
+
document.documentElement.removeAttribute('data-theme');
|
| 653 |
+
themeToggle.checked = false;
|
| 654 |
+
}
|
| 655 |
+
});
|
| 656 |
|
| 657 |
+
// Get and display endpoint URL
|
| 658 |
+
const url = new URL(window.location.href);
|
| 659 |
+
const link = url.protocol + '//' + url.host + '/hf/v1';
|
|
|
|
| 660 |
|
| 661 |
+
const endpointElements = document.querySelectorAll('#endpoint-url, #endpoint-guide');
|
| 662 |
+
for (let i = 0; i < endpointElements.length; i++) {
|
| 663 |
+
endpointElements[i].textContent = link;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
}
|
| 665 |
|
| 666 |
+
// Model tabs
|
| 667 |
+
const modelTabs = document.querySelectorAll('[data-models-tab]');
|
| 668 |
+
const modelContents = document.querySelectorAll('.models-grid.tab-content');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
|
| 670 |
+
for (let i = 0; i < modelTabs.length; i++) {
|
| 671 |
+
modelTabs[i].addEventListener('click', function() {
|
| 672 |
+
// Remove active class from all tabs
|
| 673 |
+
for (let j = 0; j < modelTabs.length; j++) {
|
| 674 |
+
modelTabs[j].classList.remove('active');
|
| 675 |
+
}
|
| 676 |
|
| 677 |
+
// Hide all tab contents
|
| 678 |
+
for (let j = 0; j < modelContents.length; j++) {
|
| 679 |
+
modelContents[j].classList.remove('active');
|
| 680 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
|
| 682 |
+
// Add active class to clicked tab
|
| 683 |
this.classList.add('active');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
|
| 685 |
+
// Show corresponding content
|
| 686 |
+
const tabId = this.getAttribute('data-models-tab') + '-models';
|
| 687 |
+
const tabContent = document.getElementById(tabId);
|
| 688 |
+
if (tabContent) {
|
| 689 |
+
tabContent.classList.add('active');
|
| 690 |
+
} else if (tabId === 'all-models') {
|
| 691 |
+
document.getElementById('all-models').classList.add('active');
|
| 692 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 693 |
});
|
| 694 |
}
|
| 695 |
|
|
|
|
| 697 |
fetch('/hf/v1/models')
|
| 698 |
.then(response => response.json())
|
| 699 |
.then(data => {
|
| 700 |
+
// Sort models alphabetically
|
| 701 |
+
data.data.sort(function(a, b) {
|
| 702 |
+
return a.id.localeCompare(b.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
});
|
| 704 |
|
| 705 |
+
const allModelsEl = document.getElementById('all-models');
|
| 706 |
+
const claudeModelsEl = document.getElementById('claude-models');
|
| 707 |
+
const gptModelsEl = document.getElementById('gpt-models');
|
| 708 |
+
const otherModelsEl = document.getElementById('other-models');
|
| 709 |
|
| 710 |
+
// Clear loading messages
|
| 711 |
+
allModelsEl.innerHTML = '';
|
| 712 |
+
claudeModelsEl.innerHTML = '';
|
| 713 |
+
gptModelsEl.innerHTML = '';
|
| 714 |
+
otherModelsEl.innerHTML = '';
|
| 715 |
|
| 716 |
+
data.data.forEach(function(model) {
|
| 717 |
+
// Create model tag
|
| 718 |
const modelEl = document.createElement('div');
|
| 719 |
modelEl.className = 'model-tag';
|
| 720 |
modelEl.textContent = model.id;
|
|
|
|
| 721 |
|
| 722 |
+
// Add to all models
|
| 723 |
+
allModelsEl.appendChild(modelEl.cloneNode(true));
|
| 724 |
+
|
| 725 |
+
// Add to specific category
|
| 726 |
+
if (model.id.includes('claude')) {
|
| 727 |
+
claudeModelsEl.appendChild(modelEl.cloneNode(true));
|
| 728 |
+
} else if (model.id.includes('gpt')) {
|
| 729 |
+
gptModelsEl.appendChild(modelEl.cloneNode(true));
|
| 730 |
+
} else {
|
| 731 |
+
otherModelsEl.appendChild(modelEl.cloneNode(true));
|
| 732 |
+
}
|
| 733 |
});
|
| 734 |
})
|
| 735 |
+
.catch(function(err) {
|
| 736 |
+
const allModelsEl = document.getElementById('all-models');
|
| 737 |
+
allModelsEl.textContent = 'Failed to load models: ' + err.message;
|
|
|
|
| 738 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 739 |
</script>
|
| 740 |
</body>
|
| 741 |
</html>
|