Deploy Your APIs

Your query programs are deployed directly from the query interface with a single click. Then explore powerful endpoint options in the Deploy section.

Deployment is instant. Click deploy in your query, and it’s immediately available as an API - no configuration needed.

How Deployment Works

Infactory provides two types of endpoints:

  • Direct Endpoints: Individual API for each query program
  • Unified Endpoint: Single natural language API that automatically selects the right query

Deploy Your Query Programs

1

Deploy from Query Interface

After successfully running a query, deploy it with one click:

  1. In your query interface (where you see the code and results)
  2. Click the “Deploy” button
  3. That’s it! Your query is now available as an API endpoint
Deploy button for immediate API deployment

Deploy button in the query interface

Deployment is instant - no configuration needed. Your query is now live as an API.

2

Explore Your Deployed APIs

Now let’s explore what’s available in the Deploy section:

  1. Navigate to the “Deploy” section in the left sidebar
  2. You’ll see three key areas:
    • API Logs: Monitor API usage and performance
    • Direct Endpoints: Test individual query APIs
    • Unified Endpoints: Natural language API access
Deploy section with API Logs, Direct Endpoints, and Unified Endpoints

Deploy section showing logs and endpoint options

3

Test Direct Endpoints

Direct endpoints give you traditional API access to each query:

  1. Click on your deployed query (e.g., “calculate_campaign_roas”)
  2. You’ll see a Postman-like interface for testing
Testing interface showing endpoint configuration and parameters

Direct endpoint testing interface

Key features:

  • Endpoint URL: Each query has a unique endpoint URL
  • Query Parameters: Customize results with filters
  • Response Preview: See actual data returned
  • Code Examples: Get implementation code in multiple languages

Try the “Send” button to execute the API call and see real results from your data.

4

Explore Unified Endpoints

The Unified Endpoint is a powerful natural language API:

  1. Click “Unified Endpoints” in the Deploy section
  2. Access the “Chat Completions” interface
Natural language API interface

Chat Completions interface for natural language queries

How it works:

  • Single Endpoint: One API URL with your project ID that handles all queries
  • Natural Language: Ask questions like “your question here”
  • Auto-routing: Automatically selects the right query program
  • Flexible: No need to remember specific endpoint names

The interface will show your specific endpoint URL including your project ID. When calling this API outside the Workshop, you must provide an API key. You can create and manage API keys in the left navigation under “API Keys”.

Example request:

curl -X 'POST' \
  'https://annalect-api.infactory.ai/v1/run/[PROJECT-ID]/chat/completions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer $INFACTORY_API_KEY' \
  -d '{
  "messages": [
    {
      "role": "user",
      "content": "your question here"
    }
  ],
  "model": "infactory-v1"
}'

Understanding Unified Endpoint Responses

The unified endpoint returns two types of responses depending on whether your question matches a deployed query:

Important: Natural language questions sent to the unified endpoint must relate to one of your deployed queries. If your question doesn’t match any deployed query, you’ll receive a list of available queries instead of data results. Always check that you have deployed relevant queries before testing the unified endpoint.

1. Matched Query Response

When your question matches a deployed query, you receive the actual data results:

{
  "id": "chatcmpl-1752600911",
  "object": "chat.completion",
  "created": 1752600911,
  "model": "infactory-v1",
  "choices": [{
    "index": 0,
    "message": {
      "role": "tool",
      "content": {
        "items": {
          "MAIN": {
            "item": {
              "rows": [
                ["ag11", 970807],
                ["ag42", 929173],
                ["ag15", 924427]
                // ... more data rows
              ]
            }
          }
        }
      }
    }
  }]
}

Key indicators of a matched query:

  • The content contains an items object with actual data
  • rows array contains your query results
  • Response includes execution details and data schema

2. Non-Matched Query Response

When your question doesn’t match any deployed query, you receive suggested questions:

{
  "id": "chatcmpl-1752600833",
  "object": "chat.completion",
  "created": 1752600833,
  "model": "infactory-v1",
  "choices": [{
    "index": 0,
    "message": {
      "role": "tool",
      "content": {
        "kind": "PublishedQueries",
        "data": {
          "project_id": "02c0b9df-874a-43fd-9cca-3e9e7da22d71",
          "queries": [
            {
              "id": "9618dc6d-ccbc-4d83-944d-8e6d1b2ad60f",
              "cue": "What's the ROAS for each campaign",
              "name": null
            },
            {
              "id": "5db2f947-c01f-495d-b3cf-4d207ea3a44d",
              "cue": "What's the ROI for each campaign or ad group?",
              "name": null
            }
            // ... more available queries
          ]
        }
      }
    }
  }]
}

Key indicators of a non-matched query:

  • The content has kind: "PublishedQueries"
  • Contains a list of available queries with their cue (suggested questions)
  • No actual data rows returned

When you receive a non-matched response, try rephrasing your question to match one of the suggested queries, or deploy a new query program that answers your specific question.

The Unified Endpoint is perfect for chatbots, voice assistants, or any application that needs flexible data access.

5

View API Logs

Monitor your API usage and performance:

  1. Click “API Logs” to see real-time activity
  2. Track requests, response times, and errors
API logs interface

API logs showing usage and performance metrics

Your APIs are live and ready! You can test them directly or integrate into your applications.

API Key Requirement for External API Calls

When running Infactory APIs outside of the Workshop interface (for example, from your own scripts, Postman, or other applications), you must provide an API key for authentication.

How to Create and Manage API Keys

  • Go to the left navigation menu in Infactory.
  • Click on API Keys (below “Projects”).
  • Here, you can:
    • Create new API keys (using the “Create API Key” button)
    • Edit or remove existing keys
    • View the status, name, and creation date of each key

Tip: Copy your API key and include it in the Authorization header as shown in the code examples:

-H 'Authorization: Bearer YOUR_API_KEY'

Never share your API key publicly. You can revoke or rotate keys at any time from the API Keys section.

Integration Examples

Direct Endpoint Example

Use direct endpoints for specific, predictable queries:

Each deployed query has its own unique endpoint URL. Find the exact URL in the Direct Endpoints interface by clicking on your query.

import requests

# Direct endpoint for ROAS calculation
# Get the endpoint URL from the Direct Endpoints interface
url = "[YOUR-ENDPOINT-URL]"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
data = response.json()

# Process results
for campaign in data['results']:
    print(f"{campaign['campaign_name']}: {campaign['roas']}")

Unified Endpoint Example

Use the unified endpoint for flexible, natural language queries:

Replace [PROJECT-ID] with your actual project ID, which you can find in the Unified Endpoints interface.

import requests

# Unified endpoint accepts natural language
url = "https://annalect-api.infactory.ai/v1/run/[PROJECT-ID]/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "messages": [
        {
            "role": "user",
            "content": "What's the ROAS for my top 5 campaigns?"
        }
    ],
    "model": "infactory-v1"
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()
print(data['choices'][0]['message']['content'])

Which Endpoint to Use?

Direct Endpoints

Use when:

  • You know exactly which query to run
  • Building automated reports
  • Need consistent, predictable results
  • Integrating into existing systems

Unified Endpoint

Use when:

  • Building conversational interfaces
  • Users ask questions in natural language
  • Need flexibility in query selection
  • Creating chatbots or voice assistants

Testing Your APIs

The Workshop provides a Postman-like interface:

  1. Go to DeployDirect Endpoints
  2. Click on your deployed query
  3. Use the built-in tester
  4. Click “Send” to execute
Direct endpoint testing interface

API Features

Your deployed APIs come with enterprise features out of the box:

Authentication

Secure API key authentication with role-based access

Rate Limiting

Configurable limits to prevent abuse

Caching

Automatic caching for improved performance

Monitoring

Real-time usage analytics and alerts

Versioning

API versioning for backward compatibility

Error Handling

Consistent error responses with helpful messages

Managing Deployments

Update a Deployed API

To update an API after modifying its query:

  1. Edit the query program
  2. Test your changes
  3. Click “Redeploy”
  4. Changes go live in seconds

Monitor Usage

Track your API performance:

API usage analytics

Real-time API analytics dashboard

Metrics available:

  • Requests per minute/hour/day
  • Average response time
  • Error rates
  • Top consumers

Troubleshooting

What’s Next?

Your APIs are live! Now let’s explore the data and integrate with your applications.

Continue to Explore

Visualize data and integrate with your apps →


Achievement Unlocked! 🎉 You’ve deployed production APIs in under 7 minutes. Most teams take weeks to reach this point!