### Clone Example Repository and Install Dependencies Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/docs.txt To interact with the deployed API, clone the example repository, navigate to the vLLM directory, and install the necessary `openai` Python library. This sets up your local environment for communication with the Beam-hosted LLM. ```bash git clone https://github.com/beam-cloud/examples.git cd examples/vllm pip install openai ``` -------------------------------- ### Install Beam Client and Configure Authentication Source: https://github.com/beam-cloud/examples/blob/main/jupyter_notebooks/beam-notebook.ipynb Install the beam-client package and configure your authentication token. This is the initial setup required to interact with the Beam platform from your notebook. ```python # Install beam-client !pip install beam-client ``` ```python # Import the Beam client import beam ``` ```python # Add your Beam API key !beam configure default --token [YOUR-BEAM-TOKEN] ``` ```python !beam config select default ``` -------------------------------- ### Install Beam Client Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl_turbo_streaming/README.md Installs the Beam Python client library. Ensure your virtual environment is activated. ```bash pip3 install beam-client ``` -------------------------------- ### Example Deployment Command Source: https://github.com/beam-cloud/examples/blob/main/endpoints/README.md This is a concrete example of deploying the `multiply` function from `app.py` with the endpoint name `my-app`. ```bash beam deploy app.py:multiply --name my-app ``` -------------------------------- ### Install Beam and Reflex Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl/README.md Install the necessary libraries for Beam and Reflex. Ensure you are in a Python virtual environment. ```bash pip3 install reflex beam-client ``` -------------------------------- ### Install MCP Server Dependencies Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/README.md Installs server dependencies using uv. Ensure Python 3.11+ and uv are installed. Update the uv path in server.py if necessary. ```bash uv sync ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl_turbo_streaming/README.md Installs Node.js dependencies for the Next.js frontend. Ensure Node.js is installed and meets Next.js requirements. ```bash cd frontend npm install ``` -------------------------------- ### Install Beam and Reflex Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl_turbo/README.md Install the necessary libraries for Beam and Reflex. Ensure you have a Python virtual environment activated. ```bash python3 -m virtualenv .venv && source .venv/bin/activate pip3 install reflex beam-client ``` -------------------------------- ### Example API Request Source: https://github.com/beam-cloud/examples/blob/main/web_scraping/headless_chrome/README.md An example of a JSON request body to capture a screenshot of 'example.com'. ```json { "url": "https://example.com" } ``` -------------------------------- ### Install MCP Server Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/README.md Installs the Beam MCP server for use with Claude Desktop. After installation, interact with the server via the Claude Desktop app. ```bash mcp install server.py ``` -------------------------------- ### Example API Call with Curl Source: https://github.com/beam-cloud/examples/blob/main/finetuning/llama/README.md Example of how to make a POST request to the deployed endpoint using curl. ```bash curl -X POST 'https://app.beam.cloud/endpoint/llama-ft/v2' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {YOUR_AUTH_TOKEN}' \ -d '{}' ``` -------------------------------- ### Run Frontend Development Server Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl_turbo_streaming/README.md Starts the Next.js development server for the frontend. Make sure the .env file is configured with Beam credentials. ```bash cd frontend npm run dev ``` -------------------------------- ### Run Reflex Frontend Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl/README.md Start the Reflex development server to run the frontend application. Navigate to the frontend directory before running this command. ```bash cd frontend && reflex run ``` -------------------------------- ### Example Deployment Output Source: https://github.com/beam-cloud/examples/blob/main/finetuning/gemma/README.md The output from the beam deploy command indicates the stages of building, syncing, and deploying the image. It also provides invocation details. ```bash => Building image => Syncing files => Deploying => Deployed 🎉 => Invocation details curl -X POST 'https://app.beam.cloud/endpoint/gemma-ft/v2' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {YOUR_AUTH_TOKEN}' \ -d '{}' ``` -------------------------------- ### Deploy Clarity Upscaler Server Source: https://github.com/beam-cloud/examples/blob/main/image_generation/clarity_upscaler/README.md Deploy the clarity-upscaler server using the beam CLI. Ensure Beam is installed and the repository is cloned before deployment. ```bash beam deploy app.py:clarity_upscaler_server ``` -------------------------------- ### Example API Call with Python Requests Source: https://github.com/beam-cloud/examples/blob/main/finetuning/llama/README.md Example of how to make a POST request to the deployed endpoint using the Python requests library. ```python response = requests.post( "https://app.beam.cloud/endpoint/llama-ft/v2", headers={ "Content-Type": "application/json", "Authorization": "Bearer YOUR_AUTH_TOKEN" }, json={ "prompt": "hi" } ) ``` -------------------------------- ### Create Virtual Environment Source: https://github.com/beam-cloud/examples/blob/main/image_generation/sdxl_turbo_streaming/README.md Creates a Python virtual environment for project dependencies. Activate it before installing packages. ```bash python3 -m virtualenv .venv && source .venv/bin/activate ``` -------------------------------- ### Monitor Gemma Fine-Tuning Progress Source: https://github.com/beam-cloud/examples/blob/main/finetuning/gemma/README.md Example output from the terminal during Gemma fine-tuning, showing build, sync, and training progress with loss and epoch information. ```bash => Building image => Syncing files ... => Running function: Loading checkpoint shards: 0%| | 0/3 [00:00 Running function: Sequence ID: CM004190.1 Length: 33445071 Description: Pan troglodytes isolate Yerkes chimp pedigree #C0471 (Clint) chromosome 21, whole genome shotgun sequence => Function complete <8bb1e80b-533c-4f91-8eba-e8a6f899ed7c> ``` ```sh $ beam ls seq Name Size Modified Time IsDir ───────────────────────────────────────────────────────────── CM004190.1.gb 7.92 KiB 5 minutes ago No ``` -------------------------------- ### Deploy Beam Application Source: https://github.com/beam-cloud/examples/blob/main/bioinformatics/dnabert/README.md Deploy your Beam application from the shell by specifying the Python file and the main function. ```shell beam deploy app.py:main ``` -------------------------------- ### Deploy vLLM Application Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/docs.txt Deploy the configured vLLM application by running the `beam deploy` command with the Python file and the application name. This command builds the image, syncs files, and deploys the API. ```bash beam deploy models.py:internvl ``` -------------------------------- ### Zonos TTS API Request Example Source: https://github.com/beam-cloud/examples/blob/main/audio_and_transcription/zonos/README.md Send a POST request to the Zonos TTS API endpoint with the specified JSON payload to convert text to speech. The 'text' field contains the content to be synthesized. ```json { "text": "Your text to convert to speech" } ``` -------------------------------- ### Deploy InstantID Model to Beam Source: https://github.com/beam-cloud/examples/blob/main/image_generation/instant_id/README.md Deploy the InstantID model as a Beam endpoint using this command. Replace `app.py:generate_image` with your specific application and entry point. ```bash beam deploy app.py:generate_image ``` -------------------------------- ### Deploy Inference Endpoint Source: https://github.com/beam-cloud/examples/blob/main/finetuning/gemma/README.md Use the beam CLI to deploy your inference script. Specify the entry point and give your endpoint a name. ```bash beam deploy inference.py:predict --name gemma-ft ``` -------------------------------- ### Zonos TTS API cURL Example Source: https://github.com/beam-cloud/examples/blob/main/audio_and_transcription/zonos/README.md This cURL command demonstrates how to make a POST request to the Zonos TTS API. It includes necessary headers for content type and authorization, along with the JSON payload containing the text to be converted. ```bash curl -X POST 'https://ff6e671a-c43d-468e-ab21-df87c8d87afb.app.beam.cloud' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer dERxHlMCz4TDU9k7cxZte_FrILTCvs0nf3KSVe8oZumoTAOa4OIkpJiyGOq_hS9nyangjUG6GC9VmswWd_Rt4g==' \ -d '{ "text": "On Beam run AI workloads anywhere with zero complexity. One line of Python, global GPUs, full control"}' ``` -------------------------------- ### Configure Gemma Inference Endpoint on Beam Source: https://github.com/beam-cloud/examples/blob/main/finetuning/gemma/README.md This decorator sets up a Beam endpoint for Gemma inference. It specifies the endpoint name, model loading on start, volume for weights, CPU, memory, GPU, Python version, packages, and autoscaling. ```python @endpoint( name="gemma-inference", on_start=load_finetuned_model, volumes=[Volume(name="gemma-ft", mount_path=MOUNT_PATH)], cpu=1, memory="16Gi", gpu="T4", image=Image( python_version="python3.9", python_packages=["transformers==4.42.0", "torch", "peft"], ), autoscaler=QueueDepthAutoscaler(max_containers=5, tasks_per_container=1), ) ``` -------------------------------- ### Define vLLM Server Configuration with Beam SDK Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/docs.txt Configure a vLLM server using the Beam SDK's VLLM class. This class accepts arguments mirroring the vLLM command-line tool. Ensure correct model name, resource allocation (CPU, memory, GPU), and vLLM-specific arguments like `trust_remote_code`, `max_model_len`, and `limit_mm_per_prompt` are set. ```python from beam.integrations import VLLM, VLLMArgs INTERNVL2_5 = "OpenGVLab/InternVL2_5-8B" internvl = VLLM( name=INTERNVL2_5.split("/")[-1], cpu=8, memory="32Gi", gpu="A10G", gpu_count=2, vllm_args=VLLMArgs( model=INTERNVL2_5, served_model_name=[INTERNVL2_5], trust_remote_code=True, max_model_len=4096, gpu_memory_utilization=0.95, limit_mm_per_prompt={"image": 2}, ) ) ``` -------------------------------- ### Deploy Whisper App to Beam Source: https://github.com/beam-cloud/examples/blob/main/audio_and_transcription/whisper_stt/README.md Use this command to deploy the `app.py` file containing the Whisper inference function to Beam. ```bash beam deploy app.py:transcribe ``` -------------------------------- ### Invoke Faster Whisper API with URL Source: https://github.com/beam-cloud/examples/blob/main/audio_and_transcription/faster_whisper/README.md Invoke the deployed Faster Whisper transcription API using cURL. This example shows how to send an audio file URL for transcription. Ensure you replace placeholders with your actual endpoint ID and authentication token. ```bash curl -X POST 'https://app.beam.cloud/endpoint/id/[YOUR-ENDPOINT-ID]' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer [YOUR-AUTH-TOKEN]' \ -d '{"url":"http://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3"}' ``` -------------------------------- ### Upload Model with Python Script Source: https://github.com/beam-cloud/examples/blob/main/image_generation/instant_id/README.md Use this command to upload the InstantID model to Beam. Ensure you have the necessary Python environment set up. ```bash python upload.py ``` -------------------------------- ### Interact with Deployed vLLM APIs via Chat Client Source: https://github.com/beam-cloud/examples/blob/main/vllm/README.md Run a Python chat client script to interact with deployed vLLM models. The script prompts for the deployment URL and allows users to chat with the model, including providing image links for multi-modal models. ```bash python chat.py ``` ```text Welcome to the CLI Chat Application! Type 'quit' to exit the conversation. Enter the app URL: https://internvl-instruct-15c4487-v1.app.beam.cloud Model OpenGVLab/InternVL2_5-8B is ready Question: What is in this image? Image link (press enter to skip): https://upload.wikimedia.org/wikipedia/commons/8/86/Wood.duck.arp.jpg Assistant: The image captures a vibrant wood duck in mid-flight, its wings spread wide as it soars through a lush field dotted with yellow flowers. The duck's head is adorned with striking red and black markings, while its body is a mix of green, white, and brown feathers. The perspective of the photo is from below, placing the duck in the center and giving a sense of its impressive wingspan. The background is a vivid green, filled with various shades of green and yellow flowers, providing a stark contrast to the duck's colorful plumage. The image is a beautiful representation of wildlife in its natural habitat ``` -------------------------------- ### Call Deployed Beam Endpoint with Curl Source: https://github.com/beam-cloud/examples/blob/main/language_models/llama3_8b/README.md Example of how to send a POST request to your deployed Beam endpoint using curl. Ensure you replace [ENDPOINT-ID] and [AUTH-TOKEN] with your actual values. The request body includes system and user messages for the Llama 3 model. ```sh curl -X POST 'https://app.beam.cloud/endpoint/id/[ENDPOINT-ID]' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -H 'Authorization: Bearer [AUTH-TOKEN]' -d '{ "messages": [ {"role": "system", "content": "You are a yoda chatbot who always responds in yoda speak!"}, {"role": "user", "content": "Who are you?"} ] }' ``` -------------------------------- ### Configure MCP Server in Claude Desktop Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/README.md JSON configuration for the MCP server in Claude Desktop. Update the 'command' and 'args' to point to your uv executable and server script. ```json { "mcpServers": { "beam-mcp": { "command": "/path/to/your/uv", "args": [ "--directory", "/path/to/your/server", "run", "server.py" ] } } } ``` -------------------------------- ### Run Fine-Tuning Job via Beam CLI Source: https://github.com/beam-cloud/examples/blob/main/finetuning/llama/README.md Executes the fine-tuning function using the Beam CLI. This command initiates the image building, file syncing, and function execution process. ```bash python [finetune.py](http://finetune.py) ``` -------------------------------- ### Serve Faster Whisper App Source: https://github.com/beam-cloud/examples/blob/main/audio_and_transcription/faster_whisper/README.md Serve the Faster Whisper transcription application using the beam CLI. This command makes the transcription API available for invocation. ```bash beam serve app.py:transcribe ``` -------------------------------- ### Deploy ComfyUI App on Beam Source: https://github.com/beam-cloud/examples/blob/main/image_generation/comfy_ui/controlnet/README.md Use this command to deploy the ComfyUI image generation application to Beam. ```bash beam deploy app.py:handler ``` -------------------------------- ### Equivalent vLLM Command Line Tool Command Source: https://github.com/beam-cloud/examples/blob/main/mcp_server/docs.txt This command shows the equivalent vLLM command-line arguments for the Python SDK configuration. It specifies the model, enables remote code trust, sets the maximum model length, and limits multi-modal prompts. ```bash vllm serve OpenGVLab/InternVL2_5-8B --trust-remote-code \ --max-model-len 4096 --limit-mm-per-prompt image=2 ``` -------------------------------- ### Execute Beam Application Source: https://github.com/beam-cloud/examples/blob/main/bioinformatics/dnabert/README.md This command executes the Beam application, initiating the image building, file syncing, and remote function execution process. It shows the expected output logs during the job execution. ```sh $ python app.py => Running function: => Building image => Using cached image => Syncing files => Files synced => Running function: => Running function: => Running function: => Running function: => Function complete <4c4ea387-f8cf-499e-9470-aba852f9a6c3> Embedding saved to: {'output_url': 'https://app.beam.cloud/output/id/53f03dfe-6564-4f89-8657-888dd01ceb62'} => Function complete Embedding saved to: {'output_url': 'https://app.beam.cloud/output/id/9a74a538-004d-4203-a09f-21dd9c488b67'} => Function complete Embedding saved to: {'output_url': 'https://app.beam.cloud/output/id/1c62ebce-6a65-429e-b32d-07bc6fe6b2bd'} => Function complete <3a988ff8-1fa0-4804-898a-1e4dc3d30c46> Embedding saved to: {'output_url': 'https://app.beam.cloud/output/id/881afdc9-e13a-4aa7-8599-b41be5f60f80'} => Function complete <436eadd4-b5d4-45af-8f33-a00c8f3e3b77> ```