Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

4.6 KB
Raw Blame

Resource: litellm_team_member_add

Add multiple members to a team with a single resource. This resource efficiently manages team members by using the appropriate API endpoints for each operation:

  • Adding new members: Uses /team/member_add endpoint
  • Updating existing members: Uses /team/member_update endpoint (preserves member identity)
  • Removing members: Uses /team/member_delete endpoint

When you modify an existing team member's attributes (like role), the resource will update the member in-place rather than deleting and re-adding them.

Example Usage

Basic Usage

resource "litellm_team_member_add" "example" {
  team_id = "team-123"
  
  member {
    user_id = "user-456"
    role    = "admin"
  }

  member {
    user_email = "[email protected]"
    role       = "user"
  }

  max_budget_in_team = 100.0
  budget_duration    = "30d"
  tpm_limit          = 100000
  rpm_limit          = 100
  allowed_models     = ["gpt-4"]
}

Complete Team Setup with Members

# First create a team
resource "litellm_team" "development" {
  team_alias = "development-team"
  max_budget = 500.0
  models     = ["gpt-4", "gpt-3.5-turbo"]
  
  team_member_permissions = [
    "create_key",
    "view_spend"
  ]
}

# Add members to the team
resource "litellm_team_member_add" "dev_team_members" {
  team_id = litellm_team.development.id
  
  # Team lead with admin role
  member {
    user_email = "[email protected]"
    role       = "admin"
  }
  
  # Regular developers
  member {
    user_email = "[email protected]"
    role       = "user"
  }
  
  member {
    user_email = "[email protected]"
    role       = "user"
  }
  
  member {
    user_id = "existing-user-123"
    role    = "user"
  }
  
  # Budget per member
  max_budget_in_team = 100.0
}

Dynamic Members Using Locals

locals {
  team_members = [
    {
      user_id  = "user-123"
      role     = "admin"
    },
    {
      user_email = "[email protected]"
      role      = "user"
    },
    {
      user_email = "[email protected]"
      role      = "user"
    }
  ]
}

resource "litellm_team_member_add" "dynamic_example" {
  team_id = "team-456"
  
  dynamic "member" {
    for_each = local.team_members
    content {
      user_id    = lookup(member.value, "user_id", null)
      user_email = lookup(member.value, "user_email", null)
      role       = member.value.role
    }
  }

  max_budget_in_team = 200.0
}

Budget Update Example

# This example demonstrates how budget updates work correctly
resource "litellm_team_member_add" "budget_example" {
  team_id = litellm_team.example.id
  
  # Initial budget of $100 per member
  max_budget_in_team = 100.0
  
  member {
    user_email = "[email protected]"
    role       = "admin"
  }
  
  member {
    user_email = "[email protected]"
    role       = "user"
  }
  
  member {
    user_id = "user123"
    role    = "user"
  }
}

# To update the budget:
# 1. Change max_budget_in_team from 100.0 to 120.0
# 2. Run terraform plan - it will show the budget change
# 3. Run terraform apply - all existing members will be updated with the new budget

Argument Reference

  • team_id - (Required) The ID of the team to add members to.
  • member - (Required) One or more member blocks defining team members. Each block supports:
    • user_id - (Optional) The ID of the user to add to the team.
    • user_email - (Optional) The email of the user to add to the team.
    • role - (Required) The role of the user in the team. Must be one of: "admin" or "user".
  • max_budget_in_team - (Optional) The maximum budget allocated for the team members.
  • budget_duration - (Optional) Duration after which each member's budget resets, for example "1h", "24h", "7d", "30d". If not set, the budget never resets.
  • tpm_limit - (Optional) Tokens per minute limit applied to each team member. Sent via /team/member_update after members are added, since /team/member_add does not accept it.
  • rpm_limit - (Optional) Requests per minute limit applied to each team member. Sent via /team/member_update after members are added, since /team/member_add does not accept it.
  • allowed_models - (Optional) List of models each team member can access. If not set, members inherit the team's default_team_member_models or all team models.

Removing budget_duration, tpm_limit, rpm_limit, or allowed_models from the configuration clears that setting on every member through /team/member_update.

Import

Team members can be imported using a composite ID of the team ID and user ID:

terraform import litellm_team_member_add.example team-123:user-456