Skip to content

Commit 16ea453

Browse files
feat(api): api update
1 parent 8ae355a commit 16ea453

3 files changed

Lines changed: 108 additions & 5 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 17
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-5d2697ad30ccbbd1502ade612deb9221a1e05e70d09a156da743d0ca120942f9.yml
3-
openapi_spec_hash: 0bde05b560fbd40711e91e6b562c3b0f
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-4b728a88b537b9f9de86512d730a8a9c1d93505d9da400098da685dbb4484e5e.yml
3+
openapi_spec_hash: 9c141a5c86f225e34d4b11c035d2dd55
44
config_hash: a4a6c3089a2e53425351cc9f42b4b5aa

src/groq/types/chat/chat_completion.py

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Optional
3+
from typing import Dict, List, Optional
44
from typing_extensions import Literal
55

66
from ..._models import BaseModel
77
from ..completion_usage import CompletionUsage
88
from .chat_completion_message import ChatCompletionMessage
99
from .chat_completion_token_logprob import ChatCompletionTokenLogprob
1010

11-
__all__ = ["ChatCompletion", "Choice", "ChoiceLogprobs", "UsageBreakdown", "UsageBreakdownModel"]
11+
__all__ = [
12+
"ChatCompletion",
13+
"Choice",
14+
"ChoiceLogprobs",
15+
"McpListTool",
16+
"McpListToolTool",
17+
"UsageBreakdown",
18+
"UsageBreakdownModel",
19+
"XGroq",
20+
"XGroqDebug",
21+
"XGroqUsage",
22+
]
1223

1324

1425
class ChoiceLogprobs(BaseModel):
@@ -36,6 +47,34 @@ class Choice(BaseModel):
3647
"""A chat completion message generated by the model."""
3748

3849

50+
class McpListToolTool(BaseModel):
51+
annotations: Optional[object] = None
52+
"""Additional metadata for the tool."""
53+
54+
description: Optional[str] = None
55+
"""Description of what the tool does."""
56+
57+
input_schema: Optional[Dict[str, object]] = None
58+
"""JSON Schema describing the tool's input parameters."""
59+
60+
name: Optional[str] = None
61+
"""The name of the tool."""
62+
63+
64+
class McpListTool(BaseModel):
65+
id: Optional[str] = None
66+
"""Unique identifier for this tool list response."""
67+
68+
server_label: Optional[str] = None
69+
"""Human-readable label for the MCP server."""
70+
71+
tools: Optional[List[McpListToolTool]] = None
72+
"""Array of discovered tools from the server."""
73+
74+
type: Optional[str] = None
75+
"""The type identifier."""
76+
77+
3978
class UsageBreakdownModel(BaseModel):
4079
model: str
4180
"""The name/identifier of the model used"""
@@ -49,6 +88,45 @@ class UsageBreakdown(BaseModel):
4988
"""List of models used in the request and their individual usage statistics"""
5089

5190

91+
class XGroqDebug(BaseModel):
92+
input_token_ids: Optional[List[int]] = None
93+
"""Token IDs for the input."""
94+
95+
input_tokens: Optional[List[str]] = None
96+
"""Token strings for the input."""
97+
98+
output_token_ids: Optional[List[int]] = None
99+
"""Token IDs for the output."""
100+
101+
output_tokens: Optional[List[str]] = None
102+
"""Token strings for the output."""
103+
104+
105+
class XGroqUsage(BaseModel):
106+
dram_cached_tokens: Optional[int] = None
107+
"""Number of tokens served from DRAM cache."""
108+
109+
sram_cached_tokens: Optional[int] = None
110+
"""Number of tokens served from SRAM cache."""
111+
112+
113+
class XGroq(BaseModel):
114+
id: str
115+
"""
116+
A groq request ID which can be used to refer to a specific request to groq
117+
support.
118+
"""
119+
120+
debug: Optional[XGroqDebug] = None
121+
"""Debug information including input and output token IDs and strings.
122+
123+
Only present when debug=true in the request.
124+
"""
125+
126+
usage: Optional[XGroqUsage] = None
127+
"""Additional Groq-specific usage metrics (hardware cache statistics)."""
128+
129+
52130
class ChatCompletion(BaseModel):
53131
id: str
54132
"""A unique identifier for the chat completion."""
@@ -68,6 +146,12 @@ class ChatCompletion(BaseModel):
68146
object: Literal["chat.completion"]
69147
"""The object type, which is always `chat.completion`."""
70148

149+
mcp_list_tools: Optional[List[McpListTool]] = None
150+
"""List of discovered MCP tools from connected servers."""
151+
152+
service_tier: Optional[Literal["auto", "on_demand", "flex", "performance"]] = None
153+
"""The service tier used for the request."""
154+
71155
system_fingerprint: Optional[str] = None
72156
"""This fingerprint represents the backend configuration that the model runs with.
73157
@@ -83,3 +167,6 @@ class ChatCompletion(BaseModel):
83167
Detailed usage breakdown by model when multiple models are used in the request
84168
for compound AI systems.
85169
"""
170+
171+
x_groq: Optional[XGroq] = None
172+
"""Groq-specific metadata for non-streaming chat completion responses."""

src/groq/types/completion_usage.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44

55
from .._models import BaseModel
66

7-
__all__ = ["CompletionUsage"]
7+
__all__ = ["CompletionUsage", "CompletionTokensDetails", "PromptTokensDetails"]
8+
9+
10+
class CompletionTokensDetails(BaseModel):
11+
reasoning_tokens: int
12+
"""Number of tokens used for reasoning (for reasoning models)."""
13+
14+
15+
class PromptTokensDetails(BaseModel):
16+
cached_tokens: int
17+
"""Number of tokens that were cached and reused."""
818

919

1020
class CompletionUsage(BaseModel):
@@ -20,9 +30,15 @@ class CompletionUsage(BaseModel):
2030
completion_time: Optional[float] = None
2131
"""Time spent generating tokens"""
2232

33+
completion_tokens_details: Optional[CompletionTokensDetails] = None
34+
"""Breakdown of tokens in the completion."""
35+
2336
prompt_time: Optional[float] = None
2437
"""Time spent processing input tokens"""
2538

39+
prompt_tokens_details: Optional[PromptTokensDetails] = None
40+
"""Breakdown of tokens in the prompt."""
41+
2642
queue_time: Optional[float] = None
2743
"""Time the requests was spent queued"""
2844

0 commit comments

Comments
 (0)