Code Velocity
AI สำหรับองค์กร

การจัดการต้นทุน AI: โปรเจกต์ Amazon Bedrock สำหรับการระบุแหล่งที่มาของค่าใช้จ่าย

·5 นาทีอ่าน·AWS·แหล่งที่มา
แชร์
แผนภาพแสดงขั้นตอนการระบุแหล่งที่มาของค่าใช้จ่ายของโปรเจกต์ Amazon Bedrock สำหรับการจัดการค่าใช้จ่าย AI ในปริมาณงานที่แตกต่างกัน

ถัดไป ใช้สคริปต์ Python ที่ให้มาเพื่อสร้างโปรเจกต์ ตรวจสอบให้แน่ใจว่าภูมิภาค AWS ของคุณได้รับการกำหนดค่าอย่างถูกต้องและคีย์ Amazon Bedrock API ของคุณถูกตั้งค่าเป็นตัวแปรสภาพแวดล้อม OPENAI_API_KEY

import os
import requests

# Configuration
BASE_URL = "https://bedrock-mantle.<YOUR-REGION-HERE>.api.aws/v1"
API_KEY  = os.environ.get("OPENAI_API_KEY")  # Your Amazon Bedrock API key

def create_project(name: str, tags: dict) -> dict:
    """สร้างโปรเจกต์ Bedrock พร้อมแท็กการจัดสรรต้นทุน"""
    response = requests.post(
        f"{BASE_URL}/organization/projects",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json"
        },
        json={"name": name, "tags": tags}
    )

    if response.status_code != 200:
        raise Exception(
            f"Failed to create project: {response.status_code} - {response.text}"
        )

    return response.json()

# ตัวอย่าง: สร้างโปรเจกต์ Production พร้อมการจัดหมวดหมู่แท็กที่สมบูรณ์
project = create_project(
    name="CustomerChatbot-Prod",
    tags={
        "Application": "CustomerChatbot",
        "Environment": "Production",
        "Team":        "CustomerExperience",
        "CostCenter":  "CC-1001",
        "Owner":       "alice"
    }
)
print(f"Created project: {project['id']}")

สคริปต์นี้จะส่งคืนรายละเอียดโปรเจกต์ รวมถึง id ที่ไม่ซ้ำกัน (เช่น proj_123) และ ARN บันทึก id นี้ไว้ เนื่องจากมีความสำคัญอย่างยิ่งต่อการเชื่อมโยงคำขออนุมานของคุณ คุณสามารถสร้างโปรเจกต์ได้สูงสุด 1,000 โปรเจกต์ต่อบัญชี AWS ซึ่งให้ความยืดหยุ่นที่เพียงพอสำหรับองค์กรขนาดใหญ่ที่สุด

การเชื่อมโยงคำขออนุมาน

เมื่อโปรเจกต์ของคุณถูกสร้างขึ้นแล้ว ให้รวม ID ของมันเข้ากับการเรียก Bedrock API ของคุณ ตัวอย่างเช่น การใช้ Responses API:

from openai import OpenAI

client = OpenAI(
    base_url="https://bedrock-mantle.<YOUR-REGION-HERE>.api.aws/v1",
    project="<YOUR-PROJECT-ID>", # ID ที่ส่งคืนเมื่อคุณสร้างโปรเจกต์
)
response = client.responses.create(
    model="openai.gpt-oss-120b",
    input="Summarize the key findings from our Q4 earnings report."
)
print(response.output_text)

ด้วยการรวมพารามิเตอร์ project อย่างสม่ำเสมอ คุณจะมั่นใจได้ถึงการระบุแหล่งที่มาของค่าใช้จ่ายที่แม่นยำสำหรับการอนุมานทุกครั้ง สำหรับแอปพลิเคชัน Bedrock ขั้นสูงเพิ่มเติม ให้พิจารณาว่าสิ่งนี้ผสานรวมกับกลยุทธ์ที่กว้างขึ้นอย่างไร เช่น การสร้าง เอนจิ้นการทดสอบ A/B ที่ขับเคลื่อนด้วย AI โดยใช้ Amazon Bedrock

การเปิดใช้งานและการวิเคราะห์ต้นทุน AI ของคุณใน AWS

ขั้นตอนสุดท้ายในการเปิดใช้งานการมองเห็นต้นทุนที่ครอบคลุมคือการเปิดใช้งานแท็กโปรเจกต์ที่คุณกำหนดเองเป็นแท็กการจัดสรรต้นทุนภายในคอนโซล AWS Billing นี่คือการกำหนดค่าเพียงครั้งเดียวที่บอกให้ AWS รวมแท็กเหล่านี้เข้าไว้ในรายงานการเรียกเก็บเงินโดยละเอียดของคุณ

การเปิดใช้งานแท็กการจัดสรรต้นทุน

ไปที่คอนโซล AWS Billing and Cost Management และทำตามคำแนะนำเพื่อเปิดใช้งานแท็กที่คุณกำหนดเอง ขอแนะนำให้ทำสิ่งนี้ทันทีที่สร้างโปรเจกต์แรกของคุณเพื่อหลีกเลี่ยงช่องว่างในข้อมูลต้นทุนของคุณ โปรดทราบว่าอาจใช้เวลาถึง 24 ชั่วโมงเพื่อให้แท็กเหล่านี้เผยแพร่และปรากฏใน AWS Cost Explorer และ AWS Data Exports อย่างสมบูรณ์

การดูต้นทุนโปรเจกต์ใน AWS Cost Explorer

เมื่อเปิดใช้งานแล้ว คุณสามารถใช้ AWS Cost Explorer เพื่อแสดงภาพและวิเคราะห์ค่าใช้จ่าย Amazon Bedrock ของคุณได้อย่างละเอียดอย่างไม่เคยมีมาก่อน คุณสามารถกรองต้นทุนของคุณตาม Service (Amazon Bedrock) และจัดกลุ่มตามแท็กการจัดสรรต้นทุนที่คุณกำหนดเอง เช่น Application, Environment หรือ CostCenter ซึ่งช่วยให้คุณสามารถ:

  • ระบุตัวขับเคลื่อนต้นทุน: ค้นหาได้อย่างรวดเร็วว่าแอปพลิเคชันหรือสภาพแวดล้อมใดที่ใช้ทรัพยากร Generative AI มากที่สุด
  • ดำเนินการเรียกเก็บเงินคืน: สร้างรายงานที่ถูกต้องสำหรับโมเดลการเรียกเก็บเงินคืนภายใน เพื่อให้แน่ใจว่าแผนกต่างๆ จะถูกเรียกเก็บเงินอย่างยุติธรรมสำหรับการใช้งาน AI ของตน
  • เพิ่มประสิทธิภาพการใช้จ่าย: ตรวจจับพื้นที่ที่ไม่มีประสิทธิภาพ เช่น โมเดลราคาแพงที่ใช้ในสภาพแวดล้อมการพัฒนาที่ไม่สำคัญ และตัดสินใจอย่างชาญฉลาดเพื่อเพิ่มประสิทธิภาพการจัดสรรทรัพยากร
  • คาดการณ์และจัดทำงบประมาณ: ปรับปรุงความแม่นยำของการคาดการณ์ค่าใช้จ่าย AI ในอนาคตโดยการวิเคราะห์ข้อมูลย้อนหลังที่แบ่งตามปริมาณงานเฉพาะ

ด้วยการนำ Amazon Bedrock Projects และกลยุทธ์การติดแท็กที่เป็นระเบียบวินัยมาใช้ องค์กรต่างๆ สามารถเปลี่ยนค่าใช้จ่าย AI ที่คลุมเครือให้เป็นข้อมูลเชิงลึกที่โปร่งใสและนำไปปฏิบัติได้จริง สิ่งนี้ไม่เพียงสนับสนุนการกำกับดูแลทางการเงินที่ดีขึ้นเท่านั้น แต่ยังส่งเสริมวัฒนธรรมของการตระหนักถึงต้นทุน ช่วยให้ทีมสามารถขยายความคิดริเริ่ม Generative AI ได้อย่างมีความรับผิดชอบและมีประสิทธิภาพ การควบคุมทรัพยากรโดยละเอียดนี้ยังเป็นกุญแจสำคัญในการผสานรวมความสามารถใหม่ๆ เช่น Amazon Bedrock AgentCore ได้อย่างมีประสิทธิภาพ

คำถามที่พบบ่อย

What are Amazon Bedrock Projects and how do they enhance AI cost management?
Amazon Bedrock Projects provide a logical boundary within the Amazon Bedrock service to represent specific AI workloads, such as applications, environments, or experiments. By associating inference requests with a project ID and attaching resource tags, organizations can gain granular visibility into their generative AI spending. This allows for precise cost attribution to individual teams, departments, or applications, facilitating accurate chargebacks, identifying cost spikes, and informing strategic optimization decisions, thereby enhancing overall financial governance and resource allocation for large-scale AI deployments.
Why is a robust tagging strategy crucial for effective cost attribution with Bedrock Projects?
A robust tagging strategy is crucial because the tags attached to Amazon Bedrock Projects become the primary dimensions for filtering and grouping cost data in AWS Cost Explorer and AWS Data Exports. By systematically tagging projects with attributes like 'Application,' 'Environment,' 'Team,' and 'CostCenter,' organizations can create a comprehensive taxonomy that mirrors their internal structure. This structured approach enables deep dives into spending patterns, helps identify high-cost areas, supports cross-departmental chargebacks, and ensures that financial reporting accurately reflects resource consumption by specific AI workloads, making cost analysis more actionable and transparent.
How do I activate cost allocation tags for Amazon Bedrock Projects in AWS Billing?
After defining your tagging strategy and creating projects with associated tags in Amazon Bedrock, you must activate these tags as cost allocation tags within the AWS Billing and Cost Management console. This crucial, one-time setup step ensures that the tags attached to your Bedrock Projects are recognized by the AWS billing pipeline. Once activated, it can take up to 24 hours for the tags to propagate and for cost data to become visible and filterable in tools like AWS Cost Explorer and AWS Data Exports. Activating these tags promptly after your initial project setup prevents gaps in your cost visibility and ensures continuous, accurate reporting.
Which Amazon Bedrock APIs support cost attribution through Project IDs?
Currently, Amazon Bedrock Projects support cost attribution via Project IDs for inference requests made through the OpenAI-compatible APIs, specifically the Responses API and the Chat Completions API. When making API calls using these endpoints, developers should include the designated Project ID to ensure that the associated costs are accurately attributed to the correct workload. It is a best practice to always explicitly specify a Project ID in API calls to avoid costs being automatically associated with the default project in your AWS account, which can hinder granular cost analysis and management efforts.
What are the benefits of using Amazon Bedrock Projects for large enterprises?
For large enterprises, Amazon Bedrock Projects offer significant benefits by providing a standardized, scalable mechanism for managing and optimizing generative AI costs. They enable granular visibility into AI spending across diverse teams, applications, and environments, supporting precise financial forecasting and budgeting. This capability is vital for complex organizational structures requiring chargebacks or detailed departmental cost allocation. Furthermore, it empowers businesses to identify inefficient workloads, optimize model usage, and make data-driven decisions to reduce overall AI infrastructure expenses, aligning technology investments with business value and ensuring responsible AI scaling.

อัปเดตข่าวสาร

รับข่าว AI ล่าสุดในกล่องจดหมายของคุณ

แชร์