Add Openai Streaming Rnのロゴ

Add Openai Streaming Rn

コミュニティ
khadinakbarlabs
add-openai-streaming-rn

Add authenticated, rate-limited AI streaming to an Expo app without exposing a provider key. Use when the user says 'add openai', 'streaming chat rn', 'gpt in app', 'ai chat ios', or 'openai streaming'.

概要

公開者khadinakbarlabs
リポジトリexpo-mobile-app-builder
スキル名add-openai-streaming-rn
スター
3
フォーク
0
同梱ファイル
1
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    khadinakbarlabsがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Add Openai Streaming Rn」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/khadinakbarlabs/expo-mobile-app-builder/tree/main/skills/add-openai-streaming-rn
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/khadinakbarlabs/expo-mobile-app-builder.git /tmp/expo-mobile-app-builder
mkdir -p .claude/skills
cp -r /tmp/expo-mobile-app-builder/skills/add-openai-streaming-rn .claude/skills/add-openai-streaming-rn
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでAdd Openai Streaming Rnを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にAdd Openai Streaming Rnを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Add Openai Streaming Rnは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Add Secure AI Streaming to React Native + Expo

Never call an AI provider directly from a mobile client. Put the provider key in server-side secret storage and require a verified user identity, bounded input, and a server-side quota before every provider request.

Required controls

  • Use an authenticated backend route. For Supabase Edge Functions, use withSupabase({ auth: 'user' }) and keep verify_jwt enabled for user-facing functions.
  • Do not accept a merely present Authorization header as proof of identity.
  • Keep provider keys in server-side secret storage only. Never use an EXPO_PUBLIC_ variable for a private provider key.
  • Enforce a per-user, server-side rate and spend quota with an atomic datastore operation before calling the provider.
  • Bound message count, message size, allowed roles, and request frequency.
  • Show a provider-specific disclosure and obtain consent before the first transfer of user content.

Implementation context

This is inert example source for the consuming app’s deployed backend, not code executed by the plugin. The backend receives an explicit provider adapter configured by the app owner in that app's server-side secret store. Do not read or reuse the installer’s machine credentials, and do not run this example as a plugin hook or local command. The mobile session token in the client example is the consuming app’s signed-in user session, not an installer token.

Authenticated Supabase Edge Function

The following pattern uses Supabase's authenticated user mode. It intentionally keeps the quota implementation server-side because its schema and atomic operation depend on the application's datastore.

ts
import { withSupabase } from 'npm:@supabase/server';

const MAX_MESSAGES = 20;
const MAX_CHARS_PER_MESSAGE = 8_000;

function isValidMessages(value: unknown): value is Array<{ role: string; content: string }> {
  return Array.isArray(value)
    && value.length > 0
    && value.length <= MAX_MESSAGES
    && value.every((message) =>
      message
      && typeof message.role === 'string'
      && ['system', 'user', 'assistant'].includes(message.role)
      && typeof message.content === 'string'
      && message.content.length > 0
      && message.content.length <= MAX_CHARS_PER_MESSAGE
    );
}

export default {
  fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
    const userId = ctx.userClaims?.sub;
    if (!userId) return new Response('Unauthorized', { status: 401 });

    const body = await req.json().catch(() => null);
    if (!body || !isValidMessages(body.messages)) {
      return new Response('Invalid request', { status: 400 });
    }

    // Implement this as one atomic server-side datastore operation. It must
    // reserve the user's allowance before any provider request is made.
    const allowed = await enforceUserQuotaAtomically(userId);
    if (!allowed) return new Response('Usage limit reached', { status: 429 });

    // Supply this adapter from the consuming app's backend. It uses only that
    // app's explicit provider configuration; it never inspects local CLI auth.
    const upstream = await streamFromAppProvider({ userId, messages: body.messages });

    if (!upstream.ok || !upstream.body) {
      return new Response('Upstream service unavailable', { status: 502 });
    }

    return new Response(upstream.body, {
      headers: {
        'Content-Type': 'text/event-stream',
        'Cache-Control': 'no-cache',
        'X-Content-Type-Options': 'nosniff',
      },
    });
  }),
};

Before deploying, verify the current authentication configuration in the provider's official documentation. Do not set auth: 'none' or disable JWT verification for a route that spends provider funds or reads user data.

enforceUserQuotaAtomically and streamFromAppProvider are required consuming-app implementations, not supplied runtime functions. The provider adapter must keep the app owner's secret in backend-only storage, restrict the destination to OpenAI's API, enforce a fixed model and output-token limit, use a bounded request timeout, and translate network failures into a generic service error. Do not deploy until both adapters exist and the security tests below pass. The plugin itself requires no provider credential and declares no provider connector.

Client streaming

Call the authenticated function through the user's session-aware client. Do not embed a provider key, server secret, or service-role key in the app.

tsx
const res = await expoFetch('https://your-project.functions.supabase.co/chat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${session?.access_token ?? ''}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ messages }),
  signal: abortRef.current.signal,
});

Treat an absent session as a local sign-in error before making this request. The backend remains the enforcement point.

Streaming parser notes

  • Use expo/fetch or another SDK-54-compatible streaming client after verifying its current compatibility.
  • Cap response size and handle malformed chunks without treating them as trusted app data.
  • Clear the AbortController in finally, and never log user prompts, credentials, or provider responses unless the product's privacy policy permits it.

Consent and privacy

Before first use, disclose the exact provider, what content leaves the device, why it is processed, and where the user can revoke consent. Do not make promises about a provider's data use unless they match the account's current agreement and published terms.

Security tests

  • A missing, malformed, expired, or arbitrary bearer value receives 401 before the provider request.
  • An overlong or malformed message array receives 400.
  • An exhausted user receives 429 and cannot trigger a provider request.
  • A provider failure returns a generic error and does not reveal a key or upstream body.

Pair with

  • 5-1-2-i-ai-disclosure
  • add-app-attestation
  • add-supabase-auth

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Add Openai Streaming Rn」では何ができますか?

Add authenticated, rate-limited AI streaming to an Expo app without exposing a provider key. Use when the user says 'add openai', 'streaming chat rn', 'gpt in app', 'ai chat ios', or 'openai streaming'.

TypingMindでAdd Openai Streaming Rnを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Add Openai Streaming Rnはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにAdd Openai Streaming Rnをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/khadinakbarlabs/expo-mobile-app-builder/tree/main/skills/add-openai-streaming-rnを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Add Openai Streaming Rnを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Add Openai Streaming Rnで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもAdd Openai Streaming Rnを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Add Openai Streaming Rn」は無料ですか?

はい。khadinakbarlabsがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇