Documentation
  • Welcome to Poe for Creators
  • Prompt Bots
    • How to create a prompt bot
    • Best practices for prompts
      • Text generation
      • Image generation
  • Server bots
    • Quick start
    • Accessing other bots on Poe
    • Using OpenAI function calling
    • Rendering an image in the response
    • Sending files with your response
    • Enabling file upload for your bot
    • Setting an introduction message
    • Updating bot settings
    • Accessing HTTP request information
    • How we cover your costs
    • Examples
    • Poe Protocol Specification
      • Concepts
      • Requests
        • query
        • settings
        • report_feedback
        • report_error
      • Samples and next steps
  • Resources
    • Creator Monetization
    • How to get distribution
    • How to contact us
    • Frequently asked questions
    • API Terms
Powered by GitBook
On this page
  1. Server bots

Rendering an image in the response

The Poe API allows you to embed images in your bot's response using Markdown syntax. The following is an example implementation describing a bot that returns a static response containing an image.

from typing import AsyncIterable
from modal import Image, Stub, asgi_app
import fastapi_poe as fp

IMAGE_URL = "https://images.pexels.com/photos/46254/leopard-wildcat-big-cat-botswana-46254.jpeg"

class SampleImageResponseBot(fp.PoeBot):
    async def get_response(
        self, request: fp.QueryRequest
    ) -> AsyncIterable[fp.PartialResponse]:
        yield fp.PartialResponse(text=f"This is a test image. ![leopard]({IMAGE_URL})")
    
REQUIREMENTS = ["fastapi-poe==0.0.24"]
image = Image.debian_slim().pip_install(*REQUIREMENTS)
stub = Stub("image-response-poe")

@stub.function(image=image)
@asgi_app()
def fastapi_app():
    bot = SampleImageResponseBot()
    app = fp.make_app(bot, allow_without_key=True)
    return app

The following is what the response looks like for someone using the above described bot.

PreviousUsing OpenAI function callingNextSending files with your response

Last updated 1 year ago

In order to run this code, you will need to setup Modal. For that, please follow Steps 1 and 2 in our . If you already have Modal set up, simply run modal deploy main.py. Modal will then deploy your bot server to the cloud and output the server url. Use that url when creating a server bot on .

Quick start
Poe