### Install Dependencies and Start Development Server Source: https://github.com/stripe/ai/blob/main/tools/typescript/examples/cloudflare/README.md Use these commands to install project dependencies and start the development server. ```bash pnpm i pnpm dev ``` -------------------------------- ### Install Dependencies and Start Server Source: https://github.com/stripe/ai/blob/main/benchmarks/subscription-gym/README.md Navigate to the server directory, install Ruby dependencies using Bundler, and start the Sinatra server. ```bash cd environment/server bundle install bundle exec ruby server.rb ``` -------------------------------- ### Install Dependencies and Start Server Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-ruby/README.md Install Ruby dependencies using Bundler and start the local server. Verify it's running by curling the /config endpoint. ```bash cd environment/$PROBLEM/server bundle install bundle exec ruby server.rb ``` ```bash curl http://localhost:4242/config ``` -------------------------------- ### Setup Environment Variables Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/meter/examples/README.md Copy the example environment file and add your Stripe and provider-specific API keys. ```bash cd examples cp .env.example .env ``` ```bash # Required for all examples STRIPE_API_KEY=sk_test_... STRIPE_CUSTOMER_ID=cus_... # Provider-specific (only required for the provider you want to test) OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... GOOGLE_GENERATIVE_AI_API_KEY=... ``` -------------------------------- ### Setup Development Environment Source: https://github.com/stripe/ai/blob/main/tools/python/README.md Set up a Python virtual environment and install development dependencies. ```sh uv venv --python 3.11 source .venv/bin/activate uv pip install -r requirements.txt ``` -------------------------------- ### Start Local Server Source: https://github.com/stripe/ai/blob/main/benchmarks/galtee-invoicing/README.md Navigate to the server directory and start the Node.js server. ```bash cd environment/server npm start ``` -------------------------------- ### Install Dependencies Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/meter/examples/README.md Navigate to the ai-sdk-billing-wrapper directory and install its dependencies. ```bash cd llm/ai-sdk-billing-wrapper npm install ``` -------------------------------- ### Run OpenAI Examples Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/provider/examples/README.md Execute the OpenAI examples using ts-node from the examples directory. ```bash cd examples npx ts-node openai.ts ``` -------------------------------- ### Run the Sinatra Application Source: https://github.com/stripe/ai/blob/main/benchmarks/checkout-gym/environment/server/README.md Execute this command to start the Sinatra server. Ensure you have a configured .env file and all dependencies installed. ```bash ruby server.rb ``` -------------------------------- ### Install Server Dependencies Source: https://github.com/stripe/ai/blob/main/benchmarks/galtee-invoicing/README.md Navigate to the server directory and install Node.js dependencies using npm. ```bash cd environment/server npm install ``` -------------------------------- ### Start the Server Source: https://github.com/stripe/ai/blob/main/benchmarks/card-element-to-checkout/README.md Starts the Flask development server. Ensure the .env file is configured with your Stripe API keys before running. ```bash cd environment/server # Create .env from the example, then fill in your Stripe keys cp .env.example .env # Edit .env and set STRIPE_SECRET_KEY and STRIPE_PUBLISHABLE_KEY python main.py ``` -------------------------------- ### Start Development Server Source: https://github.com/stripe/ai/blob/main/benchmarks/saas-starter-embedded-checkout/environment/README.md Run the Next.js development server to view the application locally. ```bash pnpm dev ``` -------------------------------- ### Install uv Package Manager Source: https://github.com/stripe/ai/blob/main/tools/python/examples/openai/customer_support/README.md Installs the uv package manager using a curl script. Ensure uv is installed before proceeding with project setup. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install Server Dependencies Source: https://github.com/stripe/ai/blob/main/benchmarks/card-element-to-checkout/README.md Installs the necessary Python dependencies for the server environment. ```bash cd environment/server pip install -e . ``` -------------------------------- ### Install Stripe Agent Toolkit Source: https://github.com/stripe/ai/blob/main/tools/python/README.md Install the library using uv pip. Ensure you have Python 3.11+. ```sh uv pip install stripe-agent-toolkit ``` -------------------------------- ### Install Server Dependencies - Bash Source: https://github.com/stripe/ai/blob/main/benchmarks/checkout-gym/README.md Navigate to the server directory and install the necessary Ruby dependencies using Bundler. ```bash cd environment/server bundle install ``` -------------------------------- ### Start MongoDB Service Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/environment/README.md Start the MongoDB Community Edition service using Homebrew. This command assumes MongoDB has been installed via Homebrew. ```bash brew services start mongodb-community@7.0 ``` -------------------------------- ### Build and Run the Server Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/README.md Navigate to the problem's server directory, restore dependencies, and run the .NET application. The server will start on http://localhost:4242. ```bash cd environment/$PROBLEM/server dotnet restore dotnet run ``` -------------------------------- ### Run the Server Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/environment/charges-on-payment-intent/server/README.md Execute the .NET application to start the server. The server will be accessible at `http://localhost:4242`. ```bash dotnet run ``` -------------------------------- ### Run Google Gemini Example Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/meter/examples/README.md Execute the Google Gemini example using ts-node to test Gemini models with the billing wrapper. ```bash npx ts-node google.ts ``` -------------------------------- ### Clone and Install Project Dependencies Source: https://github.com/stripe/ai/blob/main/benchmarks/saas-starter-embedded-checkout/environment/README.md Clone the repository and install project dependencies using pnpm. ```bash git clone https://github.com/nextjs/saas-starter cd saas-starter pnpm install ``` -------------------------------- ### Install Dependencies with Bundler Source: https://github.com/stripe/ai/blob/main/benchmarks/checkout-gym/environment/server/README.md Use this command to install all project dependencies listed in the Gemfile. ```bash bundle install ``` -------------------------------- ### Start Development Server Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/environment/README.md Run this command in your terminal to start the application's development server. Access the app via http://localhost:{process.env.PORT}. ```bash npm run dev & ``` -------------------------------- ### Copy Environment Example Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/README.md Copies the example environment file to be used for configuration. Remember to replace placeholder keys with your actual Stripe test keys. ```bash cp environment/.env.example environment/.env ``` -------------------------------- ### Install Dependencies Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/provider/examples/README.md Install the necessary dependencies for the Stripe AI SDK Provider from the ai-sdk-provider directory. ```bash cd llm/ai-sdk-provider npm install ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/stripe/ai/blob/main/tools/python/examples/openai/file_search/README.md Configure your API keys and vector store ID by copying the template and populating the values. ```bash OPENAI_API_KEY=your_openai_api_key OPENAI_VECTOR_STORE_ID=your_openai_vector_store_id STRIPE_SECRET_KEY=your_stripe_secret_key ``` -------------------------------- ### Run OpenAI Example Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/meter/examples/README.md Execute the OpenAI example using ts-node to test various OpenAI features with the billing wrapper. ```bash npx ts-node openai.ts ``` -------------------------------- ### Install @stripe/token-meter for Native SDKs Source: https://github.com/stripe/ai/blob/main/llm/README.md Use this command to install the @stripe/token-meter package for direct integration with native AI SDKs. ```bash npm install @stripe/token-meter ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/stripe/ai/blob/main/tools/python/examples/openai/customer_support/README.md Installs all project dependencies defined in the environment using uv. This command should be run after activating the virtual environment. ```bash uv sync ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/provider/examples/README.md Copy the example environment file and add your Stripe API key and Customer ID. ```bash cd examples cp .env.example .env ``` -------------------------------- ### Install @stripe/ai-sdk for Vercel AI SDK Source: https://github.com/stripe/ai/blob/main/llm/README.md Use this command to install the @stripe/ai-sdk package when integrating with the Vercel AI SDK. ```bash npm install @stripe/ai-sdk ``` -------------------------------- ### Copy .env.example for Server Configuration Source: https://github.com/stripe/ai/blob/main/benchmarks/subscription-gym/README.md Copy the example .env file to the server directory and edit it with your Stripe test keys. ```bash cp .env.example environment/server/.env ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/environment/README.md Install project dependencies using npm. This command should be run in the project's root directory. ```bash npm install ``` -------------------------------- ### Initialize Stripe Products Source: https://github.com/stripe/ai/blob/main/benchmarks/card-element-to-checkout/README.md Initializes Stripe products and prices. This is a one-time setup step performed from the project root directory. ```python STRIPE_SECRET_KEY=sk_test_xxx python environment/init_products.py ``` -------------------------------- ### Install Grader Dependencies Source: https://github.com/stripe/ai/blob/main/benchmarks/subscription-gym/README.md Install the necessary Ruby dependencies for the grader using Bundler. This only needs to be done once. ```bash cd grader bundle install ``` -------------------------------- ### Run Main Application Source: https://github.com/stripe/ai/blob/main/tools/python/examples/crewai/README.md Execute the main application script using Python. Ensure all dependencies are installed and the .env file is correctly configured. ```python python main.py ``` -------------------------------- ### Run Anthropic Claude Example Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/meter/examples/README.md Execute the Anthropic Claude example using ts-node to test Claude models with the billing wrapper. ```bash npx ts-node anthropic.ts ``` -------------------------------- ### Configure Stripe API Keys Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-ruby/README.md Set up your Stripe API keys by copying the example .env file and filling in your secret and publishable keys. ```bash # Pick a problem to work on PROBLEM=charges-on-payment-intent # or invoice-partial-payments, subscription-billing-migration # Create .env from the example cp environment/$PROBLEM/server/.env.example environment/$PROBLEM/server/.env ``` ```bash STRIPE_SECRET_KEY=sk_test_... STRIPE_PUBLISHABLE_KEY=pk_test_... ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/README.md Configuration of Stripe API keys in the environment file. Ensure you use your real Stripe test keys. ```bash STRIPE_SECRET_KEY="sk_test_..." STRIPE_PUBLIC_KEY="pk_test_..." ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/environment/charges-on-payment-intent/server/README.md Navigate to the server directory and copy the example environment file. Edit the `.env` file to include your Stripe test API keys. ```bash cd environment/server cp .env.example .env # Edit .env and add your Stripe test API keys ``` -------------------------------- ### Copy Environment File Source: https://github.com/stripe/ai/blob/main/benchmarks/furever/environment/README.md Copy the example environment file to .env to configure your Stripe API keys. This step can be skipped if a .env file already exists and is configured. ```bash cp .env.example .env ``` -------------------------------- ### Configure API Keys - Bash Source: https://github.com/stripe/ai/blob/main/benchmarks/checkout-gym/README.md Before generating new price IDs, copy the example environment file and edit it to include your Stripe test API keys. ```bash cp environment/server/.env.example environment/server/.env # Edit .env and add your Stripe test API keys ``` -------------------------------- ### Define a Basic Tool Source: https://github.com/stripe/ai/blob/main/tools/typescript/src/cloudflare/README.md Example of defining a simple tool within the MCP server that performs an addition operation. This serves as a base before monetizing. ```typescript this.server.tool('add', {a: z.number(), b: z.number()}, ({a, b}) => { return { content: [{type: 'text', text: `Result: ${a + b}`}], }; }); ``` -------------------------------- ### Docker Setup with Environment Variables Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-ruby/README.md Alternatively, set Stripe API keys as environment variables before running the Docker solution script. ```bash STRIPE_SECRET_KEY=sk_test_... ./run_solution.sh ``` -------------------------------- ### Docker Setup - Using environment variables Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/README.md Alternatively, set the Stripe API keys as environment variables before running the run_solution.sh script for the Docker workflow. ```bash export STRIPE_SECRET_KEY=sk_test_... ./run_solution.sh ``` -------------------------------- ### Run the Grader Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/README.md Copy the .env file to the grader directory, install Ruby dependencies, and execute the RSpec tests against the running server. ```bash # Copy .env so the grader can access Stripe API keys cp environment/$PROBLEM/server/.env grader/.env # Install grader dependencies (first time only) cd grader bundle install # Run the grader RSpec tests directly against the running server bundle exec rspec $PROBLEM/grade.rb --format documentation ``` -------------------------------- ### Run TypeScript Example Source: https://github.com/stripe/ai/blob/main/tools/typescript/examples/ai-sdk/README.md Execute the main TypeScript file using ts-node. The --env flag indicates that environment variables should be loaded. ```bash npx ts-node index.ts --env ``` -------------------------------- ### Run Solution Server Source: https://github.com/stripe/ai/blob/main/benchmarks/card-element-to-checkout/README.md Builds the Docker image, initializes Stripe products, and starts the solution server on localhost:5000. Use this to interact with the storefront in a browser and manually complete checkout for grading. ```bash STRIPE_SECRET_KEY=sk_test_xxx STRIPE_PUBLISHABLE_KEY=pk_test_xxx ./run_server.sh ``` -------------------------------- ### Example Response Schema for GET /products Source: https://github.com/stripe/ai/blob/main/benchmarks/galtee-invoicing/environment/PROBLEM.md This JSON structure represents the expected response for the GET /products API endpoint, detailing hike products, their Stripe IDs, pricing in multiple currencies, and names. ```json [ { "id": "fr_hike", "stripe_product_id": "prod_testproduct", "prices": { "eur": 1000, "usd": 3000 }, "name": "French Alps hike" }, ... // additional products ] ``` -------------------------------- ### Set up Environment Variables Source: https://github.com/stripe/ai/blob/main/benchmarks/saas-starter-embedded-checkout/environment/README.md Use the provided script to create the .env file for local development. ```bash pnpm db:setup ``` -------------------------------- ### Docker Setup - Using .env file Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/README.md Create a .env file in the root directory with Stripe API keys and then execute the run_solution.sh script to test the Docker workflow. ```bash cat > .env << 'EOF' STRIPE_SECRET_KEY=sk_test_... STRIPE_PUBLISHABLE_KEY=pk_test_... EOF ``` ```bash ./run_solution.sh ``` -------------------------------- ### Install MCP Package Dependency Source: https://github.com/stripe/ai/blob/main/tools/python/MIGRATION.md The `mcp` package is now a required dependency for the Stripe Agent Toolkit. Install or upgrade using pip. ```bash pip install stripe-agent-toolkit>=0.7.0 ``` -------------------------------- ### Initialize Stripe Agent Toolkit (Async) Source: https://github.com/stripe/ai/blob/main/tools/python/MIGRATION.md Migrate from synchronous initialization to asynchronous initialization using `create_stripe_agent_toolkit`. Ensure to await the initialization and close the toolkit when done. ```python # Before (v0.6.x) from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit toolkit = StripeAgentToolkit(secret_key="sk_test_...", configuration={...}) tools = toolkit.tools # After (v0.7.0+) from stripe_agent_toolkit.openai.toolkit import create_stripe_agent_toolkit toolkit = await create_stripe_agent_toolkit(secret_key="rk_test_...") tools = toolkit.get_tools() await toolkit.close() # Clean up when done ``` -------------------------------- ### Get Latest Charge Details Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/environment/charges-on-payment-intent/server/README.md Fetch the details of the latest charge for a specific `payment_intent_id` via a GET request to the `/latest-charge-details` endpoint. ```bash curl "http://localhost:4242/latest-charge-details?payment_intent_id=pi_..." ``` -------------------------------- ### Stripe Meter Output Tokens Event Example Source: https://github.com/stripe/ai/blob/main/llm/token-meter/README.md An example of the JSON structure for a Stripe meter event reporting output token usage. ```json { "event_name": "token-billing-tokens", "payload": { "stripe_customer_id": "cus_xxxxx", "value": "50", "model": "openai/gpt-4o-mini", "token_type": "output" } } ``` -------------------------------- ### Project Structure Overview Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-dotnet/README.md This diagram illustrates the directory structure for the SDK upgrade project, highlighting the 'environment', 'grader', and 'solution' folders. ```bash sdk-upgrades-dotnet/ ├── environment/ # Given to AI (old SDK code) │ ├── charges-on-payment-intent/ │ ├── invoice-partial-payments/ │ └── subscription-billing-migration/ ├── grader/ # Hidden (RSpec tests) ├── solution/ # Reference (upgraded SDK code) ├── Dockerfile ├── run_inside_docker.sh └── run_solution.sh ``` -------------------------------- ### Stripe Meter Input Tokens Event Example Source: https://github.com/stripe/ai/blob/main/llm/token-meter/README.md An example of the JSON structure for a Stripe meter event reporting input token usage. ```json { "event_name": "token-billing-tokens", "payload": { "stripe_customer_id": "cus_xxxxx", "value": "100", "model": "openai/gpt-4o-mini", "token_type": "input" } } ``` -------------------------------- ### Build and Run Java Server Source: https://github.com/stripe/ai/blob/main/benchmarks/sdk-upgrades-java/README.md Compile and run the Java server locally. Ensure you navigate to the server directory first. ```bash cd environment/$PROBLEM/server mvn install -DskipTests mvn exec:java -Dexec.mainClass="com.stripe.sample.Server" ``` -------------------------------- ### Install Stripe Agent Toolkit (TypeScript) Source: https://github.com/stripe/ai/blob/main/README.md Install the Stripe Agent Toolkit for TypeScript using npm. This package is for using the toolkit, not for modifying it. ```sh npm install @stripe/agent-toolkit ``` -------------------------------- ### Install Stripe Agent Toolkit (Python) Source: https://github.com/stripe/ai/blob/main/README.md Install the Stripe Agent Toolkit for Python using pip. This package is for using the toolkit, not for modifying it. ```sh pip install stripe-agent-toolkit ``` -------------------------------- ### Basic Stripe AI SDK Setup Source: https://github.com/stripe/ai/blob/main/llm/ai-sdk/provider/examples/README.md Initialize the Stripe AI SDK provider with your API key and an optional default customer ID. Then, create a model instance. ```typescript import { createStripe } from '@stripe/ai-sdk/provider'; import { generateText } from 'ai'; const stripeLLM = createStripe({ apiKey: process.env.STRIPE_API_KEY!, customerId: process.env.STRIPE_CUSTOMER_ID, // Optional default }); const model = stripe('openai/gpt-5'); ``` -------------------------------- ### Install Stripe.js via npm Source: https://github.com/stripe/ai/blob/main/providers/claude/plugin/skills/upgrade-stripe/SKILL.md Install the Stripe.js package using npm. Major npm versions correspond to specific Stripe.js versions and their paired API versions. ```bash npm install @stripe/stripe-js ``` -------------------------------- ### Get Configuration Source: https://github.com/stripe/ai/blob/main/benchmarks/subscription-gym/environment/server/README.md Returns the Stripe publishable key for client-side integration. ```APIDOC ## GET /config ### Description Returns the Stripe publishable key for client-side integration. ### Method GET ### Endpoint /config ### Response #### Success Response (200) - **publishableKey** (string) - The Stripe publishable key. ``` -------------------------------- ### Get Subscription Status Source: https://github.com/stripe/ai/blob/main/benchmarks/subscription-gym/environment/server/README.md Retrieves the status of a subscription using its ID. ```APIDOC ## GET /subscription-status ### Description Retrieves the status of a subscription. ### Method GET ### Endpoint /subscription-status ### Parameters #### Query Parameters - **subscription_id** (string) - Required - The ID of the subscription to retrieve the status for. ### Response #### Success Response (200) - **status** (string) - The current status of the subscription. ``` -------------------------------- ### Initialize Toolkit with Factory Function Source: https://github.com/stripe/ai/blob/main/tools/typescript/MIGRATION.md Use the `createStripeAgentToolkit` factory function for a recommended, one-step initialization process. Ensure to import from the correct SDK path. ```typescript import {createStripeAgentToolkit} from '@stripe/agent-toolkit/openai'; // Also available: /ai-sdk, /langchain, /modelcontextprotocol const toolkit = await createStripeAgentToolkit({ secretKey: 'rk_test_...', configuration: {}, }); const tools = toolkit.getTools(); // ... use tools ... await toolkit.close(); // Clean up when done ``` -------------------------------- ### Get Customer Bookings Source: https://github.com/stripe/ai/blob/main/benchmarks/galtee-basic/environment/PROBLEM.md Lists all purchases for a given customer, including their status. ```APIDOC ## GET /customer/:email/bookings ### Description Lists all purchases for the given customer. This should include the data from the bookings table in addition to a `status` field. `status` should be ‘complete’ if fully paid, ‘refunded’ if refunded, ‘incomplete’ if incomplete. ### Method GET ### Endpoint /customer/:email/bookings ### Parameters #### Path Parameters - **email** (string) - Required - The email of the customer whose bookings are to be listed. ``` -------------------------------- ### Get Products Source: https://github.com/stripe/ai/blob/main/benchmarks/galtee-basic/environment/PROBLEM.md Retrieves a list of all products offered by Galtee in JSON format. ```APIDOC ## GET /products ### Description Retrieves a list of all products offered in JSON format according to the existing products table in the database. ### Method GET ### Endpoint /products ``` -------------------------------- ### Initialize Toolkit using Constructor and initialize() Source: https://github.com/stripe/ai/blob/main/tools/python/MIGRATION.md Instantiate `StripeAgentToolkit` separately and call `initialize()` later for delayed initialization or dependency injection. Ensure to close the toolkit. ```python from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit toolkit = StripeAgentToolkit(secret_key="rk_test_...") # Later, when ready to use: async def main(): await toolkit.initialize() try: tools = toolkit.get_tools() # ... use tools ... finally: await toolkit.close() ```