Repository navigation
ConvertTo‑ShpTokenCount
Estimates the number of model tokens in a piece of text.
ConvertTo-ShpTokenCount [-Text] <String[]> [<CommonParameters>]
Returns an approximate token count for the supplied text using a pure PowerShell heuristic, so a caller can size a prompt - and, with Get-ShpCostEstimate, its likely cost - before sending it. No exact tokenizer is used (that would need a compiled dependency, which this module avoids); the estimate blends a character-per-token ratio with a word count and is deliberately conservative. Treat the result as a guide, not an exact figure: the service's reported usage is authoritative. Accepts text from the pipeline.
ConvertTo-ShpTokenCount -Text 'Summarise PowerShell splatting in two lines.'
Returns an approximate token count for the prompt.
Get-Content .\prompt.txt -Raw | ConvertTo-ShpTokenCount
Estimates the token count of a prompt held in a file.
The text to estimate. Accepts one or more strings (each is estimated and the counts are summed). Mandatory.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- Clear-ShpChat
- Clear-ShpContext
- Clear-ShpRedactionPolicy
- Clear-ShpToolPolicy
- Clear-ShpUsage
- Compress-ShpChat
- ConvertTo-ShpAnnotation
- ConvertTo-ShpOtelTrace
- ConvertTo-ShpTokenCount
- Get-ShpChat
- Get-ShpChatCheckpoint
- Get-ShpContext
- Get-ShpContextReport
- Get-ShpCosineSimilarity
- Get-ShpCostEstimate
- Get-ShpDefault
- Get-ShpMcpServer
- Get-ShpModel
- Get-ShpModelName
- Get-ShpRedactionPolicy
- Get-ShpTool
- Get-ShpToolPolicy
- Get-ShpUsage
- Initialize-Shp
- Invoke-Shp
- Invoke-ShpBatch
- Invoke-ShpEval
- Invoke-ShpSubagent
- Register-ShpMcpServer
- Register-ShpTool
- Request-ShpEmbedding
- Resolve-ShpError
- Restore-ShpChat
- Save-ShpChat
- Select-ShpModel
- Set-ShpContext
- Set-ShpRedactionPolicy
- Set-ShpToolPolicy
- Start-ShpChat
- Test-ShpCiReadiness
- Unregister-ShpMcpServer
- Unregister-ShpTool