Images

Sending image response

@app.get( "/image", # Set what the media type will be and prevent FastAPI from adding "application/json" responses = { 200: { "content": {"image/png": {}} } }, response_class=Response ) def get_image() image_bytes: bytes = generate_cat_picture() # media_type here sets the media type of the actual response sent to the client. return Response(content=image_bytes, media_type="image/png")