A Vercel serverless function that handles model calls for the SVGBench evaluation pipeline.
- Receives SVGBench evaluation requests via POST
- Makes model calls to Fireworks AI
- Returns model responses for local SVG evaluation
- Handles CORS and provides health check endpoint
-
Install Vercel CLI:
npm install -g vercel
-
Navigate to this directory:
cd eval_protocol/quickstart/svg_agent/vercel_svg_server -
Create .env file with your API key (optional):
cp .env.example .env # Edit .env and add your actual API keyNote: The API key can be provided either:
- In the request payload (automatically handled by
RemoteRolloutProcessor) - In a local
.envfile (fallback option)
- In the request payload (automatically handled by
-
Start local development server:
vercel dev
Your function will be available at
http://localhost:3000
-
Follow steps 1-2 above
-
Deploy to Vercel:
vercel deploy
Follow the prompts to:
- Create a new project (or link existing)
- Set project name (e.g.,
svgbench-server)
-
Deploy to production:
vercel --prod
Note: The function receives the API key in the request payload (automatically handled by RemoteRolloutProcessor), but can also fall back to a local .env file if needed.
The function provides these endpoints:
Processes SVGBench evaluation requests.
Request format:
{
"model": "fireworks_ai/accounts/fireworks/models/gpt-oss-120b",
"messages": [
{
"role": "user",
"content": "Your SVG generation prompt here"
}
],
"model_base_url": "https://api.fireworks.ai/inference/v1",
"metadata": {
"rollout_id": "some-unique-id"
},
"api_key": "your-fireworks-api-key",
"completion_params": {
"temperature": 0.8,
"max_tokens": 32768
}
}Note: The api_key field is automatically populated by RemoteRolloutProcessor from your local FIREWORKS_API_KEY environment variable.
Response format:
{
"status": "completed",
"rollout_id": "some-unique-id",
"choices": [
{
"message": {
"role": "assistant",
"content": "SVG code generated by model"
}
}
]
}Health check endpoint - returns server status.
For local testing with vercel dev:
@evaluation_test(
rollout_processor=RemoteRolloutProcessor(
remote_base_url="http://localhost:3000",
timeout_seconds=300,
),
# ... other params
)For testing with deployed function:
@evaluation_test(
rollout_processor=RemoteRolloutProcessor(
remote_base_url="https://vercel-svg-server.vercel.app",
timeout_seconds=300,
),
# ... other params
)Note: The RemoteRolloutProcessor automatically passes your local FIREWORKS_API_KEY environment variable to the Vercel function.
The function uses the following priority for API keys:
- Request payload (
req.api_key) - Automatically provided byRemoteRolloutProcessor - Local .env file (
FIREWORKS_API_KEY) - Fallback for local development - Environment variable - Fallback for other deployment methods
This flexible approach works for both local development and production deployment.
- Remote: Model calls (handled by this serverless function)
- Local: SVG extraction, rendering, evaluation, scoring (handled by test client)
This keeps the heavy SVG processing local while scaling model calls in the cloud.