For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://modelgates.ai/docs/_mcp/server.
Get a single API key
GET https://modelgates.ai/api/v1/keys/
Get a single API key by hash. Management key required.
Reference: https://modelgates.ai/docs/api/api-reference/api-keys/get-key
OpenAPI Specification
yaml
openapi: 3.1.0info: title: ModelGates API version: 1.0.0paths: /keys/: get: operationId: get-key summary: Get a single API key description: >- Get a single API key by hash. [Management key](/docs/guides/overview/auth/management-api-keys) required. tags: - subpackage_apiKeys parameters: - name: hash in: path description: The hash identifier of the API key to retrieve required: true schema: type: string - name: Authorization in: header description: API key as bearer token in Authorization header required: true schema: type: string responses: '200': description: API key details content: application/json: schema: $ref: '#/components/schemas/API Keys_getKey_Response_200' '401': description: Unauthorized - Authentication required or invalid credentials content: application/json: schema: $ref: '#/components/schemas/UnauthorizedResponse' '404': description: Not Found - Resource does not exist content: application/json: schema: $ref: '#/components/schemas/NotFoundResponse' '429': description: Too Many Requests - Rate limit exceeded content: application/json: schema: $ref: '#/components/schemas/TooManyRequestsResponse' '500': description: Internal Server Error - Unexpected server error content: application/json: schema: $ref: '#/components/schemas/InternalServerResponse'servers: - url: https://modelgates.ai/api/v1components: schemas: KeysHashGetResponsesContentApplicationJsonSchemaData: type: object properties: byok_usage: type: number format: double description: Total external BYOK usage (in USD) for the API key byok_usage_daily: type: number format: double description: External BYOK usage (in USD) for the current UTC day byok_usage_monthly: type: number format: double description: External BYOK usage (in USD) for current UTC month byok_usage_weekly: type: number format: double description: >- External BYOK usage (in USD) for the current UTC week (Monday-Sunday) created_at: type: string description: ISO 8601 timestamp of when the API key was created creator_user_id: type: - string - 'null' description: >- The user ID of the key creator. For organization-owned keys, this is the member who created the key. For individual users, this is the user's own ID. disabled: type: boolean description: Whether the API key is disabled expires_at: type: - string - 'null' format: date-time description: >- ISO 8601 UTC timestamp when the API key expires, or null if no expiration hash: type: string description: Unique hash identifier for the API key include_byok_in_limit: type: boolean description: Whether to include external BYOK usage in the credit limit label: type: string description: Human-readable label for the API key limit: type: - number - 'null' format: double description: Spending limit for the API key in USD limit_remaining: type: - number - 'null' format: double description: Remaining spending limit in USD limit_reset: type: - string - 'null' description: Type of limit reset for the API key name: type: string description: Name of the API key updated_at: type: - string - 'null' description: ISO 8601 timestamp of when the API key was last updated usage: type: number format: double description: Total ModelGates credit usage (in USD) for the API key usage_daily: type: number format: double description: ModelGates credit usage (in USD) for the current UTC day usage_monthly: type: number format: double description: ModelGates credit usage (in USD) for the current UTC month usage_weekly: type: number format: double description: >- ModelGates credit usage (in USD) for the current UTC week (Monday-Sunday) workspace_id: type: string description: The workspace ID this API key belongs to. required: - byok_usage - byok_usage_daily - byok_usage_monthly - byok_usage_weekly - created_at - creator_user_id - disabled - hash - include_byok_in_limit - label - limit - limit_remaining - limit_reset - name - updated_at - usage - usage_daily - usage_monthly - usage_weekly - workspace_id description: The API key information title: KeysHashGetResponsesContentApplicationJsonSchemaData API Keys_getKey_Response_200: type: object properties: data: $ref: >- #/components/schemas/KeysHashGetResponsesContentApplicationJsonSchemaData description: The API key information required: - data title: API Keys_getKey_Response_200 UnauthorizedResponseErrorData: type: object properties: code: type: integer message: type: string metadata: type: - object - 'null' additionalProperties: description: Any type required: - code - message description: Error data for UnauthorizedResponse title: UnauthorizedResponseErrorData UnauthorizedResponse: type: object properties: error: $ref: '#/components/schemas/UnauthorizedResponseErrorData' modelgates_metadata: type: - object - 'null' additionalProperties: description: Any type user_id: type: - string - 'null' required: - error description: Unauthorized - Authentication required or invalid credentials title: UnauthorizedResponse NotFoundResponseErrorData: type: object properties: code: type: integer message: type: string metadata: type: - object - 'null' additionalProperties: description: Any type required: - code - message description: Error data for NotFoundResponse title: NotFoundResponseErrorData NotFoundResponse: type: object properties: error: $ref: '#/components/schemas/NotFoundResponseErrorData' modelgates_metadata: type: - object - 'null' additionalProperties: description: Any type user_id: type: - string - 'null' required: - error description: Not Found - Resource does not exist title: NotFoundResponse TooManyRequestsResponseErrorData: type: object properties: code: type: integer message: type: string metadata: type: - object - 'null' additionalProperties: description: Any type required: - code - message description: Error data for TooManyRequestsResponse title: TooManyRequestsResponseErrorData TooManyRequestsResponse: type: object properties: error: $ref: '#/components/schemas/TooManyRequestsResponseErrorData' modelgates_metadata: type: - object - 'null' additionalProperties: description: Any type user_id: type: - string - 'null' required: - error description: Too Many Requests - Rate limit exceeded title: TooManyRequestsResponse InternalServerResponseErrorData: type: object properties: code: type: integer message: type: string metadata: type: - object - 'null' additionalProperties: description: Any type required: - code - message description: Error data for InternalServerResponse title: InternalServerResponseErrorData InternalServerResponse: type: object properties: error: $ref: '#/components/schemas/InternalServerResponseErrorData' modelgates_metadata: type: - object - 'null' additionalProperties: description: Any type user_id: type: - string - 'null' required: - error description: Internal Server Error - Unexpected server error title: InternalServerResponse securitySchemes: apiKey: type: http scheme: bearer description: API key as bearer token in Authorization headerSDK Code Examples
python
import requests url = "https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943" headers = {"Authorization": "Bearer <token>"} response = requests.get(url, headers=headers) print(response.json())javascript
const url = 'https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}go
package main import ( "fmt" "net/http" "io") func main() { url := "https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer <token>") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }ruby
require 'uri'require 'net/http' url = URI("https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943") http = Net::HTTP.new(url.host, url.port)http.use_ssl = true request = Net::HTTP::Get.new(url)request["Authorization"] = 'Bearer <token>' response = http.request(request)puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;import com.mashape.unirest.http.Unirest; HttpResponse<String> response = Unirest.get("https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943") .header("Authorization", "Bearer <token>") .asString();php
<?phprequire_once('vendor/autoload.php'); $client = new \GuzzleHttp\Client(); $response = $client->request('GET', 'https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943', [ 'headers' => [ 'Authorization' => 'Bearer <token>', ],]); echo $response->getBody();csharp
using RestSharp; var client = new RestClient("https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943");var request = new RestRequest(Method.GET);request.AddHeader("Authorization", "Bearer <token>");IRestResponse response = client.Execute(request);swift
import Foundation let headers = ["Authorization": "Bearer <token>"] let request = NSMutableURLRequest(url: NSURL(string: "https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.httpMethod = "GET"request.allHTTPHeaderFields = headers let session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) }}) dataTask.resume()