Core Concepts

This guide explains the fundamental concepts you need to understand when using LangMart. Understanding these concepts will help you make the most of the platform.

Models and Providers

What is a Provider?

A provider is a company that offers AI/LLM services. LangMart integrates with multiple providers, giving you access to their models through a single API.

Provider Description Popular Models
OpenAI Creator of GPT models gpt-4o, gpt-4-turbo, gpt-3.5-turbo
Anthropic Creator of Claude claude-3.5-sonnet, claude-3-opus
Google Google AI gemini-1.5-pro, gemini-pro
Groq Fast inference llama-3.3-70b, mixtral-8x7b
Mistral European AI company mistral-large, mistral-medium
OpenRouter Meta-router 100+ models from various sources

What is a Model?

A model is a specific AI system trained for language tasks. Each model has unique characteristics:

Characteristic Description Example
Context Window Maximum input/output tokens 128K tokens
Capabilities What the model can do Vision, Tool Use, Reasoning
Speed Response latency Fast (< 1s), Medium, Slow
Quality Output quality level High, Medium, Standard
Cost Price per 1K tokens $0.001 - $0.06

Model Naming Convention

LangMart uses a standardized naming format:

provider/model-name

Examples:

  • openai/gpt-4o - GPT-4o from OpenAI
  • anthropic/claude-3.5-sonnet - Claude 3.5 Sonnet from Anthropic
  • groq/llama-3.3-70b-versatile - Llama 3.3 70B on Groq infrastructure

Model Categories

Models are organized into categories based on their capabilities:

Category Description Use Cases
Chat Conversational models Chatbots, assistants
Completion Text completion Code completion, writing
Embedding Text to vectors Search, similarity
Image Generation Text to image Art, design
Vision Image understanding Analysis, description

Connections

What is a Connection?

A connection links LangMart to a provider using your API credentials. Connections enable:

  • Using your own provider API keys
  • Accessing provider-specific features
  • Managing rate limits and quotas
  • Tracking usage per connection

Connection Types

Type Description Best For
Platform Default LangMart's shared keys Getting started, testing
Individual Your personal API key Personal projects
Organization Shared team API key Team collaboration

Creating a Connection

  1. Go to Connections in the sidebar
  2. Click Add Connection
  3. Select the provider
  4. Enter your API key
  5. (Optional) Set rate limits and quotas
  6. Click Create

Connection Scope

Scope Access Visibility
Individual Only you Private
Organization All org members Shared

Why Use Your Own Connection?

Reason Benefit
Higher Limits Provider rate limits don't compete with others
Direct Billing Pay the provider directly, potentially cheaper
Enterprise Features Access enterprise-only features
Compliance Meet data residency requirements
Custom Endpoints Connect to private deployments

Credits and Billing

How Billing Works

LangMart uses a credit-based billing system:

  1. Purchase Credits - Buy credits through the platform
  2. Use Credits - Credits are deducted based on token usage
  3. Track Spending - Monitor usage in real-time

Understanding Token Pricing

AI models charge based on tokens - pieces of text roughly equivalent to 4 characters or 3/4 of a word.

Input: "Hello, how are you today?" = ~7 tokens
Output: "I'm doing great, thanks for asking!" = ~9 tokens

Price Calculation

Cost = (Input Tokens * Input Price) + (Output Tokens * Output Price)

Example:

  • Model: groq/llama-3.3-70b-versatile
  • Input: 1,000 tokens @ $0.0006/1K = $0.0006
  • Output: 500 tokens @ $0.0008/1K = $0.0004
  • Total: $0.001

Billing Modes

Mode Description Who Pays
Member Pays Individual users pay from their balance You
Org Pays Organization covers usage costs Organization

Viewing Usage

Track your usage in multiple ways:

View Location Shows
Dashboard Home page Today's summary
Analytics Analytics page Detailed breakdown
Requests Request Logs Per-request details
Billing Settings > Billing Invoices and history

Cost Optimization Tips

  1. Choose the Right Model - Don't use GPT-4 when GPT-3.5 suffices
  2. Optimize Prompts - Shorter prompts = fewer input tokens
  3. Set Max Tokens - Limit output length when appropriate
  4. Use Caching - Avoid duplicate requests
  5. Monitor Usage - Set up alerts for spending thresholds

Organizations and Teams

What is an Organization?

An organization is a group of users who share resources. Organizations enable:

  • Team collaboration
  • Shared connections
  • Centralized billing
  • Access control

Organization Roles

Role Permissions
Owner Full control, billing, delete org
Admin Manage members, connections, settings
Member Use resources, view analytics
Viewer Read-only access

Creating an Organization

  1. Go to Organizations in the sidebar
  2. Click Create Organization
  3. Enter organization name and details
  4. Invite team members

Switching Organizations

If you belong to multiple organizations:

  1. Click your profile icon
  2. Select Switch Organization
  3. Choose the organization

Inviting Members

  1. Go to Organizations > Your Organization
  2. Click Invite Member
  3. Enter email address
  4. Select role
  5. Send invitation

Invitees receive an email with a link to join.

Gateway Architecture (Simplified)

Understanding LangMart's architecture helps you troubleshoot and optimize.

What is a Gateway?

A gateway is a server component that processes your API requests. LangMart uses different gateway types for different purposes.

Request Flow

Your App                LangMart                 Provider
   │                       │                        │
   │──── API Request ─────>│                        │
   │                       │                        │
   │                       │── Validate & Route ───>│
   │                       │                        │
   │                       │<──── Provider API ─────│
   │                       │                        │
   │<─── Response ─────────│                        │

Gateway Types

Type Purpose When Used
Type 1 Full platform gateway Most requests
Type 2 Cloud provider routing Provider connections

What This Means for You

  • Reliability - Multiple gateways provide redundancy
  • Performance - Requests are routed optimally
  • Flexibility - Different providers handled appropriately

API Compatibility

OpenAI Compatibility

LangMart's API is designed to be a drop-in replacement for OpenAI's API:

# OpenAI
from openai import OpenAI
client = OpenAI(api_key="sk-...")

# LangMart - just change base_url
from openai import OpenAI
client = OpenAI(
    api_key="sk-langmart-...",
    base_url="https://api.langmart.ai/v1"
)

Supported Endpoints

Endpoint Status Description
/v1/chat/completions Full Chat completions
/v1/completions Full Text completions
/v1/embeddings Full Text embeddings
/v1/models Full List models
/v1/images/generations Partial Image generation

Provider-Specific Features

Some provider features are available through LangMart:

Feature Support Notes
Streaming Yes Server-Sent Events
Function Calling Yes Tools/functions
Vision Yes Image inputs
JSON Mode Yes Structured output

Alerts and Monitoring

Setting Up Alerts

Alerts notify you when certain conditions are met:

Alert Type Trigger Example
Usage Token/request threshold > 1M tokens/day
Cost Spending threshold > $50/day
Error Rate Error percentage > 5% errors

Creating an Alert

  1. Go to Alerts in the sidebar
  2. Click Create Alert
  3. Select alert type and condition
  4. Set threshold value
  5. Choose notification method
  6. Save

Notification Methods

Method Description
In-App Notification in dashboard
Email Email to your address
Webhook HTTP POST to your endpoint

Glossary

Term Definition
API Key Secret credential for API authentication
Connection Link between LangMart and a provider using your credentials
Credits LangMart's billing currency
Gateway Server component that processes requests
Model A specific AI system (e.g., GPT-4o)
Organization Group of users sharing resources
Provider Company offering AI services (e.g., OpenAI)
Token Unit of text for pricing (~4 characters)

Next Steps

Now that you understand the core concepts: