Skip to content
Open
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ https://relay.byokrelay.com

Free to use. Open CORS (any origin). [Health check →](https://relay.byokrelay.com/health)

## Svelte stores

```bash
npm install @byok-relay/svelte
```

```svelte
<script>
import { createByokRelayStore, createStreamingChatStore } from '@byok-relay/svelte';
import { onMount } from 'svelte';

const relay = createByokRelayStore({ appId: 'myapp' });
const chat = createStreamingChatStore({ appId: 'myapp', provider: 'openai' });

onMount(() => relay.register());
Comment on lines +33 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File list ==\n'
git ls-files README.md packages/svelte/README.md packages/svelte src 2>/dev/null || true

printf '\n== Search for register() definitions/usages ==\n'
rg -n "register\(\)" README.md packages/svelte/README.md packages/svelte src . --glob '!**/node_modules/**' || true

printf '\n== Search for createByokRelayStore ==\n'
rg -n "createByokRelayStore|createStreamingChatStore|onMount" README.md packages/svelte/README.md packages/svelte src . --glob '!**/node_modules/**' || true

Repository: avikalpg/byok-relay

Length of output: 17793


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant README snippets with line numbers.
for f in README.md packages/svelte/README.md; do
  if [ -f "$f" ]; then
    printf '\n== %s ==\n' "$f"
    nl -ba "$f" | sed -n '1,120p'
  fi
done

Repository: avikalpg/byok-relay

Length of output: 214


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the implementation of register() and any error handling around it.
files=$(git ls-files | tr '\n' '\0' | xargs -0 rg -n --no-heading "register\\s*\\(" --glob '!**/node_modules/**' 2>/dev/null | cut -d: -f1 | sort -u)

printf 'Candidate files:\n%s\n' "$files"

# If we can find a likely implementation file, print the relevant slice.
for f in $(printf '%s\n' "$files" | head -n 20); do
  [ -f "$f" ] || continue
  printf '\n== %s ==\n' "$f"
  nl -ba "$f" | sed -n '1,220p'
done

Repository: avikalpg/byok-relay

Length of output: 342


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== README snippets ==\n'
for f in README.md packages/svelte/README.md; do
  if [ -f "$f" ]; then
    printf '\n-- %s --\n' "$f"
    nl -ba "$f" | sed -n '25,55p'
  fi
done

printf '\n== register() implementation candidates ==\n'
rg -n --glob '!**/node_modules/**' "register\\s*[:=]\\s*(async\\s*)?\\(|async\\s+register\\s*\\(|class .*register\\s*\\(" .

Repository: avikalpg/byok-relay

Length of output: 237


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== packages/svelte/src/index.js around createByokRelayStore/register ==\n'
sed -n '147,220p' packages/svelte/src/index.js

printf '\n== README.md snippet around onMount ==\n'
sed -n '25,40p' README.md

printf '\n== packages/svelte/README.md snippets around onMount ==\n'
sed -n '30,45p;132,148p;198,214p;306,318p' packages/svelte/README.md

Repository: avikalpg/byok-relay

Length of output: 4798


Handle the register() rejection in the Svelte examples.

relay.register() is async and rethrows on failure, so calling it directly from onMount can surface an unhandled rejection. Use an explicit .catch(...) in README.md and the repeated snippets in packages/svelte/README.md.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 33 - 36, The Svelte README examples call
relay.register() directly from onMount, but register() is async and can reject,
causing an unhandled rejection. Update the example in README.md and the repeated
snippet in packages/svelte/README.md to handle the returned promise explicitly
with a .catch(...) on relay.register(), using the existing createByokRelayStore
and onMount example so failures are safely handled.

</script>

{#if $chat.isStreaming}
<p>{$chat.streamingContent}<span>▋</span></p>
<button on:click={chat.stopStreaming}>Stop</button>
{/if}
```

Four stores: `createByokRelayStore` · `createChatStore` · `createStreamingChatStore` · `createRelayHealthStore`. SvelteKit SSR-safe. See [`packages/svelte`](./packages/svelte).

## For AI coding agents

If you're using a coding agent (Cursor, Claude Code, Copilot, Codex, etc.), install the skill and let it handle the integration:
Expand Down
56 changes: 56 additions & 0 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,62 @@ const TOKEN = await fetch('https://your-relay.com/users', {

Apache 2.0 — free to self-host or build on top of.

## Svelte Stores (`@byok-relay/svelte`)

For Svelte and SvelteKit apps:

```bash
npm install @byok-relay/svelte
```

```svelte
<script>
import { createByokRelayStore, createStreamingChatStore } from '@byok-relay/svelte';
import { onMount, onDestroy } from 'svelte';
const relay = createByokRelayStore({ appId: 'myapp' });
const chat = createStreamingChatStore({ appId: 'myapp', provider: 'openai' });
onMount(() => relay.register());
</script>
<!-- Use $relay.isRegistered, $chat.messages, $chat.isStreaming, $chat.streamingContent -->
```

Stores: `createByokRelayStore` · `createChatStore` · `createStreamingChatStore` · `createRelayHealthStore`.
SSR-safe for SvelteKit. npm: https://www.npmjs.com/package/@byok-relay/svelte

## React Hooks (`@byok-relay/react`)

```bash
npm install @byok-relay/react
```

Hooks: `useByokRelay` · `useChat` · `useStreamingChat` · `useRelayHealth`.
npm: https://www.npmjs.com/package/@byok-relay/react

## Vue Composables (`@byok-relay/vue`)

```bash
npm install @byok-relay/vue
```

Composables: `useByokRelay` · `useChat` · `useStreamingChat` · `useRelayHealth`.
npm: https://www.npmjs.com/package/@byok-relay/vue

## MCP Server (`@byok-relay/mcp`)

For Claude Desktop, Claude Code, Cursor, Windsurf:

```bash
npx -y @byok-relay/mcp
```

Tools: `byok_relay_health` · `byok_relay_register` · `byok_relay_store_key` · `byok_relay_request` · `byok_relay_chat` · `byok_relay_stats`.
npm: https://www.npmjs.com/package/@byok-relay/mcp

## API Reference

OpenAPI 3.0 spec (machine-readable): https://relay.byokrelay.com/openapi.json
YAML: https://relay.byokrelay.com/openapi.yaml

## Links

- GitHub: https://github.com/avikalpg/byok-relay
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "byok-relay",
"version": "1.0.1",
"description": "BYOK relay server stores user API keys encrypted and proxies requests to AI providers",
"description": "BYOK relay server \u2014 stores user API keys encrypted and proxies requests to AI providers",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
Expand All @@ -19,5 +19,8 @@
"engines": {
"node": ">=18"
},
"license": "Apache-2.0"
"license": "Apache-2.0",
"workspaces": [
"packages/*"
]
}
Loading