Last reviewed: 2026-06-08

Direct answer

To smoke-test the CometAPI chat completion contract, send a minimal POST /v1/chat/completions request with a valid API key and a short messages array, then assert that the HTTP status is 200, the response body is valid JSON, and the choices[0].message.content field is a non-empty string. If those three assertions pass, the core contract is intact. If any assertion fails, capture the HTTP status code and the raw response body before escalating.

The CometAPI chat completions endpoint is documented at apidoc.cometapi.com/api/text/chat. That reference page defines the POST method, the Authorization: Bearer authentication scheme, the required model and messages body fields, the choices array response structure, and the error response shape — all of the contract areas a smoke test must cover. Confirm every field name and accepted value against that reference before relying on them in an automated pipeline.

The current model identifiers available for your account are listed at apidoc.cometapi.com/overview/models. Do not hard-code a model string from an example without first verifying it is active for your key.

For deeper production validation steps beyond a quick smoke test, see Validate CometAPI Chat Completions for Production.

Who this is for

This guide is for:

  • Backend engineers integrating the CometAPI chat completions endpoint for the first time and wanting a quick sanity check before full integration testing.
  • Operators running pre-deployment checklists against a staging or production environment.
  • On-call engineers who need a fast, repeatable manual check after an incident or configuration change.
  • Teams migrating from another OpenAI-compatible provider and verifying that the CometAPI endpoint responds to the same basic request shape.

You are assumed to have an active CometAPI account, a valid API key, and access to a command-line HTTP client such as curl or an equivalent tool. Exact authentication details and API key management steps are available from the CometAPI documentation overview and the CometAPI help center.

Key takeaways

  • The smoke test is a fast go/no-go check, not a full contract audit. Its purpose is to confirm the endpoint is reachable, authenticates correctly, and returns a structurally valid response.
  • According to the chat completions reference, the endpoint accepts a POST request with model, messages, and optional fields such as stream and temperature. Verify the exact required and optional field names from that reference before use in automated tests.
  • The response structure documented at apidoc.cometapi.com/api/text/chat includes a choices array, where each element contains a message object with role and content fields. A passing smoke test must confirm this structure is present.
  • A smoke test must not assert on specific model output text, exact token counts, latency, pricing, or quota availability — those vary by account, model, and environment.
  • Log the HTTP status, a redacted request summary, and the response structure fields after every smoke-test run to build an audit trail.
  • If the endpoint returns an unexpected HTTP status or a malformed response, capture the raw response body before retry. Do not assume a transient error without a recorded observation.
  • Confirm the available model identifiers for your account by checking the CometAPI models reference — do not hard-code a model string without verifying it is active for your key.

Smoke-test workflow

Setup assumptions

Before running the smoke test, confirm:

  1. You have a valid CometAPI API key available in your environment. Do not embed it in scripts; use an environment variable such as COMET_API_KEY.
  2. You have identified a model identifier that is available for your account. Verify the current model list at the CometAPI models reference and confirm the string to use in the model field.
  3. You know the base URL for the API. The CometAPI documentation overview is the authoritative starting point for confirming the current base URL and authentication scheme before constructing your request.
  4. You have a test environment or a low-stakes account context suitable for sending real requests.

Happy-path request plan

The CometAPI chat completions reference documents the endpoint as POST /v1/chat/completions, using Bearer token authentication via the Authorization header, with model and messages as the core required body fields. The messages array contains objects with role and content string fields. Optional fields documented include stream (boolean) and temperature (numeric). Verify the current accepted value ranges and any additional required fields from the official reference before integrating.

Example request structure (confirm all field names, types, and values against apidoc.cometapi.com/api/text/chat before use in automated tests):

curl -X POST https://<base-url>/v1/chat/completions \
  -H "Authorization: Bearer $COMET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<verified-model-id>",
    "messages": [
      {"role": "user", "content": "Respond with the single word: pong"}
    ],
    "stream": false
  }'

Minimum assertions for a passing happy-path run:

  1. HTTP response status is 200
  2. Response Content-Type header indicates JSON
  3. Response body is valid, parseable JSON
  4. choices field is present and is a non-empty array (as documented in the response schema at apidoc.cometapi.com/api/text/chat)
  5. choices[0].message is present and has a non-empty content field
  6. No error field is present at the top level of the response

Error-path check

Run a second request with an invalid or missing API key to confirm that the endpoint correctly rejects unauthenticated requests:

  • What to send: the same request shape, but with the Authorization header omitted or set to a deliberately invalid value
  • Expected result: a non-200 HTTP status (typically 401 or 403) and a response body that includes an error indicator
  • Minimum assertions for a passing error-path run:
    1. HTTP status is not 200
    2. Response body is valid JSON
    3. Response body contains an error field or an error object — confirm the exact error response shape from the chat completions reference

Example error-path request:

curl -X POST https://<base-url>/v1/chat/completions \
  -H "Authorization: Bearer invalid-token-smoke-test" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<verified-model-id>",
    "messages": [{"role": "user", "content": "ping"}]
  }'

A passing error-path check returns a non-200 status (typically 401) and a JSON body containing an error descriptor. If the endpoint returns 200 for an invalid key, escalate immediately — that is a contract violation.

What the smoke test must not assert

  • Specific model output text or wording — LLM outputs are non-deterministic
  • Exact token counts in usage fields
  • Response latency or time-to-first-token
  • Pricing, billing amounts, or account balance
  • Model availability for other accounts or regions
  • Quota or rate limit values — these are account-specific
  • Uptime or availability guarantees

Sanitized log-record template

Record these fields after each smoke-test run. Use placeholder values; do not log real API keys, full prompts, or full responses in shared logs.

smoke_test_run:
  run_id: "<run-identifier, e.g. smoke-20260608-001>"
  timestamp_utc: "<ISO 8601 timestamp>"
  environment: "<staging | production | local>"
  endpoint_base: "<base URL used, without key>"
  model_id_used: "<verified model identifier>"
  request_summary: "messages_count=1, stream=false"
  http_status: "<e.g. 200>"
  response_structure_valid: "<true | false>"
  choices_present: "<true | false>"
  content_non_empty: "<true | false>"
  error_field_present: "<true | false>"
  auth_rejection_status: "<e.g. 401>"
  auth_rejection_error_body_valid: "<true | false>"
  pass_fail: "<PASS | FAIL>"
  notes: "<any anomalies observed>"

Failure modes

These are real operational failure modes you may encounter while running CometAPI chat completion smoke tests:

  • Authentication rejected (401/403) with a key that appears valid. The most common cause is an Authorization header format mismatch. Confirm the exact header name and Bearer prefix format from the chat completions reference. A trailing space, a missing Bearer prefix, or use of the wrong header name (e.g., X-API-Key instead of Authorization) will all produce a 401. Capture the raw response body — the error object often names the specific auth failure reason.
  • Model not found or model identifier rejected (400 or 404). If the model field contains a string that is not active for your account, the endpoint returns a non-200 status. Do not assume a model identifier from documentation examples is active for your key. Always verify against the CometAPI models reference before the smoke-test run.
  • Malformed request body (400 Bad Request). Missing required fields, incorrect JSON structure, or an unsupported value type for temperature or stream will produce a 400 with an error body. Assert that the messages array is not empty and that each element has both role and content string fields. If the error body names the offending field, log it before retrying.
  • Valid JSON structure but empty choices array. The response passes JSON parsing and the choices key is present, but the array is empty. This is a contract violation — a passing smoke test requires at least one element in choices. Log the full response body and the model identifier used, then consult the CometAPI help center if the problem persists.
  • Non-JSON response body (502/503/504 or proxy error). Network or gateway issues can return HTML error pages or empty bodies with a 5xx status. The smoke test must always check that the response body is parseable JSON before asserting on its fields. Log the raw body and HTTP status; do not treat this as a model or auth failure.
  • Streaming response received when stream: false was sent. If your HTTP client or a proxy layer buffers a streaming response and presents it as a single body, the JSON parse will fail or choices will be absent. Confirm your client is not transparently following redirects to a streaming path. Use stream: false explicitly in the smoke-test request body and verify the Content-Type response header is application/json, not text/event-stream.
  • Smoke test passes locally but fails in CI/CD. Environment-specific differences — different base URLs, missing environment variables, proxy rules, or network egress restrictions — are the most common cause. Record the exact base URL, header set, and environment variable names used in each run so the difference is visible in the log.

For persistent failures that are not resolved by rechecking the request format, use the CometAPI help center as the escalation path.

Sources checked

Contract details to verify

AreaWhat to verifySource URLAccessedSafe candidate wording
Endpoint pathConfirm the exact HTTP path for chat completionshttps://apidoc.cometapi.com/api/text/chat2026-06-08“POST /v1/chat/completions as documented; verify current path from official reference”
HTTP methodConfirm the required HTTP verb (POST as described in docs)https://apidoc.cometapi.com/api/text/chat2026-06-08“POST method as documented; confirm in official reference”
Authentication schemeConfirm the exact header name, token format, and Bearer prefix requirementshttps://apidoc.cometapi.com/api/text/chat2026-06-08“Bearer token via Authorization header; verify exact format from official docs”
Required request fieldsConfirm which fields are required vs. optional (model, messages, role, content)https://apidoc.cometapi.com/api/text/chat2026-06-08“Verify required fields from the official request schema before integration”
Optional request fieldsConfirm accepted names and value ranges for stream, temperature, max_tokenshttps://apidoc.cometapi.com/api/text/chat2026-06-08“Optional fields include stream, temperature; verify exact names and ranges”
Response shapeConfirm top-level fields including choices, message, content, usagehttps://apidoc.cometapi.com/api/text/chat2026-06-08“Response includes a choices array; verify all field names from official response schema”
Error response shapeConfirm error object structure and HTTP status codes for auth failure, bad request, and server errorhttps://apidoc.cometapi.com/api/text/chat2026-06-08“Verify error field names and expected HTTP status codes from official error reference”
Support escalationConfirm the correct support path for persistent endpoint failureshttps://apidoc.cometapi.com/support/help-center2026-06-08“Use the official help center for escalation beyond self-serve troubleshooting”

Reader next step

If the happy-path and error-path assertions both pass, your CometAPI chat completion contract is confirmed at the smoke-test level. The recommended next steps:

  1. Sign up or log in at CometAPI to access the dashboard, create or rotate API keys, and review your model access list.
  2. Use Review a CometAPI chat completions contract as the next comparison point to understand what a contract incident looks like and what log evidence to preserve.
  3. Keep Validate CometAPI Chat Completions for Production nearby for the full pre-production validation checklist, which covers permission checks, quota limits, and integration testing beyond the smoke-test scope.
  4. If your integration also uses the Responses endpoint, see Smoke-test CometAPI chat completions safely for a lightweight, repeatable approach to keeping smoke tests in sync with your deployment cadence.

Use Review a CometAPI chat completions contract as the next comparison point. Keep Validate CometAPI Chat Completions for Production nearby for setup and permission checks.

After the source checks, request assumptions, and review owner are clear, use CometAPI as the reference gateway only for the request paths, model routes, or cost checks the team has actually verified.

FAQ

What is the minimum viable smoke test for the CometAPI chat completions endpoint? Send a POST request with a valid API key, a confirmed model identifier, and a single-message array. Assert HTTP 200, valid JSON response, and a non-empty choices[0].message.content. That covers the core contract path as documented in the chat completions reference.

How do I find the right model identifier to use in my smoke-test request? Check the CometAPI models reference for the current list of available model identifiers. Do not hard-code a model string from documentation examples without confirming it is active for your account.

Should I test with stream: true in a smoke test? For a minimal smoke test, use stream: false so you get a single complete JSON response that is easy to assert against. If your integration uses streaming, add a separate streaming smoke-test after the non-streaming path passes.

What should I do if the smoke test returns a 401 or 403? Confirm that your API key is valid, active, and has the correct permissions. Check the authentication header name and Bearer token format against the official chat completions docs. If the key looks correct, consult the help center.

What HTTP status should the endpoint return for a missing API key? Typically 401 for a missing or malformed token. Confirm the exact expected status and error response format from the official reference, as this can vary by implementation.

Can I assert on the exact text content in the response? No. LLM outputs are non-deterministic. Assert only on the structural presence and non-emptiness of the content field, not on its exact value.

Where can I find more about production-readiness checks beyond this smoke test? See Validate CometAPI Chat Completions for Production for a deeper validation checklist.

Is there a way to get started with CometAPI right now? Visit CometAPI to sign up and access the dashboard where you can create API keys and review your model access.